diff --git a/frontend/core/navigation/src/commonMain/kotlin/at/mocode/frontend/core/navigation/DeepLinkHandler.kt b/frontend/core/navigation/src/commonMain/kotlin/at/mocode/frontend/core/navigation/DeepLinkHandler.kt index 2a831150..dacbb5e2 100644 --- a/frontend/core/navigation/src/commonMain/kotlin/at/mocode/frontend/core/navigation/DeepLinkHandler.kt +++ b/frontend/core/navigation/src/commonMain/kotlin/at/mocode/frontend/core/navigation/DeepLinkHandler.kt @@ -25,7 +25,6 @@ class DeepLinkHandler( return processDeepLink(parsed) } - // TODO: Implement deep link processing logic private fun processDeepLink(deepLink: DeepLink): Boolean { val route = cleanRoute(deepLink.route) diff --git a/frontend/core/network/src/jsMain/kotlin/at/mocode/frontend/core/network/PlatformConfig.js.kt b/frontend/core/network/src/jsMain/kotlin/at/mocode/frontend/core/network/PlatformConfig.js.kt index e3f89964..fe5182ba 100644 --- a/frontend/core/network/src/jsMain/kotlin/at/mocode/frontend/core/network/PlatformConfig.js.kt +++ b/frontend/core/network/src/jsMain/kotlin/at/mocode/frontend/core/network/PlatformConfig.js.kt @@ -4,12 +4,14 @@ import kotlinx.browser.window @Suppress("UnsafeCastFromDynamic", "EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") actual object PlatformConfig { + + private val globalScope: dynamic + get() = js("typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}))") + actual fun resolveApiBaseUrl(): String { - // 1) Prefer a global JS variable (can be injected by index.html or nginx) - val global = - js("typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}))") + // 1) Prefer a global JS variable (injected by main.kt via AppConfig) val fromGlobal = try { - (global.API_BASE_URL as? String)?.trim().orEmpty() + (globalScope.API_BASE_URL as? String)?.trim().orEmpty() } catch (_: dynamic) { "" } @@ -17,20 +19,17 @@ actual object PlatformConfig { console.log("[PlatformConfig] Resolved API_BASE_URL from global: $fromGlobal") return fromGlobal.removeSuffix("/") } - // 2) Try window location origin (same origin gateway/proxy setup) val origin = try { window.location.origin } catch (_: dynamic) { null } - if (!origin.isNullOrBlank()) { val resolvedUrl = origin.removeSuffix("/") + "/api" console.log("[PlatformConfig] Resolved API_BASE_URL from window.location.origin: $resolvedUrl") return resolvedUrl } - // 3) Fallback to the local gateway directly (e.g., for tests without a window) val fallbackUrl = "http://localhost:8081/api" console.log("[PlatformConfig] Fallback API_BASE_URL: $fallbackUrl") @@ -38,11 +37,9 @@ actual object PlatformConfig { } 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 : {}))") + // 1) Prefer a global JS variable (injected by main.kt via AppConfig) val fromGlobal = try { - (global.KEYCLOAK_URL as? String)?.trim().orEmpty() + (globalScope.KEYCLOAK_URL as? String)?.trim().orEmpty() } catch (_: dynamic) { "" } @@ -50,7 +47,6 @@ actual object PlatformConfig { 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 @@ -62,7 +58,6 @@ actual object PlatformConfig { 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")