Switch runtime config handling to JSON-based Caddy templates in frontend.
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m37s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m28s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m1s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m53s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m37s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m28s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 2m1s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m53s
This commit is contained in:
@@ -12,16 +12,28 @@
|
||||
<div id="ComposeTarget">
|
||||
<div class="loading">Loading...</div>
|
||||
</div>
|
||||
<script>
|
||||
// Laufzeit-Konfiguration — kein Rebuild nötig (SSoT: .env via Caddy-Templates oder query params)
|
||||
// Caddy verarbeitet index.html als text/html-Template (Standard) und ersetzt .Env-Variablen.
|
||||
// Lokal (webpack-dev-server): Template-Tags bleiben Literal-Strings → startsWith('{{') Prüfung greift.
|
||||
|
||||
<!--
|
||||
Schritt 1: Caddy füllt dieses JSON-Template aus.
|
||||
Der Inhalt ist reines JSON, was Syntaxkonflikte mit JS vermeidet.
|
||||
-->
|
||||
<script id="app-config" type="application/json">
|
||||
{
|
||||
"apiBaseUrl": "{{.Env.API_BASE_URL}}",
|
||||
"keycloakUrl": "{{.Env.KEYCLOAK_URL}}"
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
// Schritt 2: Das Haupt-Skript liest die Konfiguration aus dem JSON-Block.
|
||||
(function () {
|
||||
try {
|
||||
const configElement = document.getElementById('app-config');
|
||||
const configJson = configElement.textContent || '{}';
|
||||
const config = JSON.parse(configJson);
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
// Caddy injiziert: {{.Env.API_BASE_URL}} → z.B. "https://app.mo-code.at"
|
||||
const apiFromCaddy = `{{.Env.API_BASE_URL}}`;
|
||||
const apiFromCaddy = config.apiBaseUrl;
|
||||
const apiOverride = params.get('apiBaseUrl');
|
||||
globalThis.API_BASE_URL = apiOverride
|
||||
? apiOverride.replace(/\/$/, '')
|
||||
@@ -29,8 +41,7 @@
|
||||
? apiFromCaddy.replace(/\/$/, '')
|
||||
: 'http://' + window.location.origin.replace(/\/$/, ''));
|
||||
|
||||
// Caddy injiziert: {{.Env.KEYCLOAK_URL}} → z.B. "https://auth.mo-code.at"
|
||||
const kcFromCaddy = `{{.Env.KEYCLOAK_URL}}`;
|
||||
const kcFromCaddy = config.keycloakUrl;
|
||||
const kcOverride = params.get('keycloakUrl');
|
||||
globalThis.KEYCLOAK_URL = kcOverride
|
||||
? kcOverride.replace(/\/$/, '')
|
||||
@@ -39,12 +50,14 @@
|
||||
: 'http://' + window.location.hostname + ':8180');
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error loading runtime configuration:', e);
|
||||
globalThis.API_BASE_URL = 'http://localhost:8081';
|
||||
globalThis.KEYCLOAK_URL = 'http://localhost:8180';
|
||||
}
|
||||
})();
|
||||
// KMP bundle liest globalThis.API_BASE_URL und globalThis.KEYCLOAK_URL in PlatformConfig.js
|
||||
</script>
|
||||
|
||||
<script src="web-app.js"></script>
|
||||
<script>
|
||||
// Register Service Worker only in non-localhost environments
|
||||
|
||||
Reference in New Issue
Block a user