Fix: Align table formatting in Zora documentation and update Keycloak-related configurations
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 7m42s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m1s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m58s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m34s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 7m42s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m1s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m58s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m34s
This commit is contained in:
+3
-2
@@ -1,6 +1,7 @@
|
||||
package at.mocode.frontend.core.auth.data
|
||||
|
||||
import at.mocode.frontend.core.domain.AppConstants
|
||||
import at.mocode.frontend.core.network.PlatformConfig
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.request.forms.*
|
||||
@@ -24,8 +25,8 @@ data class LoginResponse(
|
||||
*/
|
||||
class AuthApiClient(
|
||||
private val httpClient: HttpClient,
|
||||
// Keycloak Basis-URL (z. B. http://localhost:8180)
|
||||
private val keycloakBaseUrl: String = AppConstants.KEYCLOAK_URL,
|
||||
// Keycloak Basis-URL — wird zur Laufzeit via PlatformConfig aufgelöst (SSoT: .env / globalThis.KEYCLOAK_URL)
|
||||
private val keycloakBaseUrl: String = PlatformConfig.resolveKeycloakUrl(),
|
||||
// Realm-Name in Keycloak
|
||||
private val realm: String = AppConstants.KEYCLOAK_REALM,
|
||||
// Client-ID (Public Client empfohlen für Frontend-Flows)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package at.mocode.frontend.core.network
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
expect object PlatformConfig {
|
||||
fun resolveApiBaseUrl(): String
|
||||
fun resolveKeycloakUrl(): String
|
||||
}
|
||||
|
||||
+32
@@ -36,4 +36,36 @@ actual object PlatformConfig {
|
||||
console.log("[PlatformConfig] Fallback API_BASE_URL: $fallbackUrl")
|
||||
return fallbackUrl
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
// 1) Prefer a global JS variable injected by index.html at runtime
|
||||
val global =
|
||||
js("typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}))")
|
||||
val fromGlobal = try {
|
||||
(global.KEYCLOAK_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) {
|
||||
console.log("[PlatformConfig] Resolved KEYCLOAK_URL from global: $fromGlobal")
|
||||
return fromGlobal.removeSuffix("/")
|
||||
}
|
||||
|
||||
// 2) Derive from window.location.hostname with default Keycloak port
|
||||
val hostname = try {
|
||||
window.location.hostname
|
||||
} catch (_: dynamic) {
|
||||
null
|
||||
}
|
||||
if (!hostname.isNullOrBlank()) {
|
||||
val resolvedUrl = "http://$hostname:8180"
|
||||
console.log("[PlatformConfig] Resolved KEYCLOAK_URL from window.location.hostname: $resolvedUrl")
|
||||
return resolvedUrl
|
||||
}
|
||||
|
||||
// 3) Fallback for local development
|
||||
val fallbackUrl = "http://localhost:8180"
|
||||
console.log("[PlatformConfig] Fallback KEYCLOAK_URL: $fallbackUrl")
|
||||
return fallbackUrl
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -9,4 +9,10 @@ actual object PlatformConfig {
|
||||
// Fallback default to the local gateway
|
||||
return "http://localhost:8081"
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
val env = System.getenv("KEYCLOAK_URL")?.trim().orEmpty()
|
||||
if (env.isNotEmpty()) return env.removeSuffix("/")
|
||||
return "http://localhost:8180"
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -4,6 +4,14 @@ import kotlinx.browser.window
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual object PlatformConfig {
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
val fromGlobal = getGlobalKeycloakUrl()
|
||||
if (fromGlobal.isNotEmpty()) return fromGlobal.removeSuffix("/")
|
||||
val hostname = getWindowHostname()
|
||||
if (hostname.isNotEmpty()) return "http://$hostname:8180"
|
||||
return "http://localhost:8180"
|
||||
}
|
||||
|
||||
actual fun resolveApiBaseUrl(): String {
|
||||
// 1) Prefer a global JS variable (can be injected by index.html or nginx)
|
||||
val fromGlobal = getGlobalApiBaseUrl()
|
||||
@@ -36,3 +44,20 @@ private fun getGlobalApiBaseUrl(): String = js(
|
||||
})()
|
||||
"""
|
||||
)
|
||||
|
||||
private fun getGlobalKeycloakUrl(): String = js(
|
||||
"""
|
||||
(function() {
|
||||
var global = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
|
||||
return (global.KEYCLOAK_URL && typeof global.KEYCLOAK_URL === 'string') ? global.KEYCLOAK_URL : "";
|
||||
})()
|
||||
"""
|
||||
)
|
||||
|
||||
private fun getWindowHostname(): String = js(
|
||||
"""
|
||||
(function() {
|
||||
try { return window.location.hostname || ""; } catch(e) { return ""; }
|
||||
})()
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -12,23 +12,32 @@
|
||||
<div id="ComposeTarget">
|
||||
<div class="loading">Loading...</div>
|
||||
</div>
|
||||
<script>
|
||||
// Prefer explicit query param override (?apiBaseUrl=http://host:port),
|
||||
// then fall back to same-origin. This avoids Docker secrets and works with Nginx proxy.
|
||||
<script>
|
||||
// Laufzeit-Konfiguration — kein Rebuild nötig (SSoT: .env via Nginx/Caddy oder query params)
|
||||
// API_BASE_URL: Prefer explicit query param, then same-origin (Nginx proxy)
|
||||
// KEYCLOAK_URL: Prefer explicit query param, then derive from window.location.hostname + port 8180
|
||||
(function () {
|
||||
try {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const override = params.get('apiBaseUrl');
|
||||
if (override) {
|
||||
globalThis.API_BASE_URL = override.replace(/\/$/, '');
|
||||
} else {
|
||||
globalThis.API_BASE_URL = window.location.origin.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
// API Base URL
|
||||
const apiOverride = params.get('apiBaseUrl');
|
||||
globalThis.API_BASE_URL = apiOverride
|
||||
? apiOverride.replace(/\/$/, '')
|
||||
: window.location.origin.replace(/\/$/, '');
|
||||
|
||||
// Keycloak URL — gleiche IP wie die App, Port 8180
|
||||
const kcOverride = params.get('keycloakUrl');
|
||||
globalThis.KEYCLOAK_URL = kcOverride
|
||||
? kcOverride.replace(/\/$/, '')
|
||||
: 'http://' + window.location.hostname + ':8180';
|
||||
|
||||
} catch (e) {
|
||||
globalThis.API_BASE_URL = 'http://localhost:8081';
|
||||
globalThis.KEYCLOAK_URL = 'http://localhost:8180';
|
||||
}
|
||||
})();
|
||||
// KMP bundle will read globalThis.API_BASE_URL in PlatformConfig.js
|
||||
// KMP bundle liest globalThis.API_BASE_URL und globalThis.KEYCLOAK_URL in PlatformConfig.js
|
||||
</script>
|
||||
<script src="web-app.js"></script>
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user