fix(web-app): remove unused sqlite.worker.js and wasi-dummy.js, update Config.kt and service worker logic
- Deleted `sqlite.worker.js` and `wasi-dummy.js` to clean up outdated resources. - Updated `Config.kt` to use a shared `Json` instance for deserialization. - Revised service worker for cache versioning and to bypass caching of `web-app.js` and `.map` files. - Enhanced debug logging and improved handling of uncaught errors in new `sqlite.worker.js`. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
@@ -3,6 +3,8 @@ import kotlinx.coroutines.await
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
private val AppJson = Json { ignoreUnknownKeys = true }
|
||||
|
||||
@Serializable
|
||||
data class AppConfig(
|
||||
val apiBaseUrl: String,
|
||||
@@ -18,7 +20,7 @@ suspend fun loadAppConfig(): AppConfig {
|
||||
return fallbackFromGlobal()
|
||||
}
|
||||
val text = response.text().await()
|
||||
Json.decodeFromString(AppConfig.serializer(), text)
|
||||
AppJson.decodeFromString(AppConfig.serializer(), text)
|
||||
} catch (e: dynamic) {
|
||||
console.error("[Config] Error loading config:", e)
|
||||
// Fallback: Caddy-injizierte Werte aus index.html (globalThis.API_BASE_URL / KEYCLOAK_URL)
|
||||
@@ -28,10 +30,10 @@ suspend fun loadAppConfig(): AppConfig {
|
||||
|
||||
private fun fallbackFromGlobal(): AppConfig {
|
||||
val apiBase = (js("globalThis.API_BASE_URL") as? String)
|
||||
?.takeIf { it.isNotBlank() && !it.startsWith("\${") }
|
||||
?.takeIf { it.isNotBlank() && !it.startsWith($$"${") }
|
||||
?: window.location.origin
|
||||
val kcUrl = (js("globalThis.KEYCLOAK_URL") as? String)
|
||||
?.takeIf { it.isNotBlank() && !it.startsWith("\${") }
|
||||
?.takeIf { it.isNotBlank() && !it.startsWith($$"${") }
|
||||
console.log("[Config] Fallback: apiBaseUrl=$apiBase, keycloakUrl=$kcUrl")
|
||||
return AppConfig(apiBaseUrl = apiBase, keycloakUrl = kcUrl)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user