fix(web-app): Caddy .Env-Template-Injection für API_BASE_URL + KEYCLOAK_URL
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m33s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m35s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 1m57s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m42s
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Successful in 8m33s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 7m35s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Successful in 1m57s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 1m42s
Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
@@ -13,24 +13,30 @@
|
||||
<div class="loading">Loading...</div>
|
||||
</div>
|
||||
<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
|
||||
// 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.
|
||||
(function () {
|
||||
try {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
// API Base URL
|
||||
const apiOverride = params.get('apiBaseUrl');
|
||||
// Caddy injiziert: {{.Env.API_BASE_URL}} → z.B. "https://app.mo-code.at"
|
||||
const apiFromCaddy = '{{.Env.API_BASE_URL}}';
|
||||
const apiOverride = params.get('apiBaseUrl');
|
||||
globalThis.API_BASE_URL = apiOverride
|
||||
? apiOverride.replace(/\/$/, '')
|
||||
: window.location.origin.replace(/\/$/, '');
|
||||
: (apiFromCaddy && !apiFromCaddy.startsWith('{{')
|
||||
? apiFromCaddy.replace(/\/$/, '')
|
||||
: window.location.origin.replace(/\/$/, ''));
|
||||
|
||||
// Keycloak URL — gleiche IP wie die App, Port 8180
|
||||
const kcOverride = params.get('keycloakUrl');
|
||||
// Caddy injiziert: {{.Env.KEYCLOAK_URL}} → z.B. "https://auth.mo-code.at"
|
||||
const kcFromCaddy = '{{.Env.KEYCLOAK_URL}}';
|
||||
const kcOverride = params.get('keycloakUrl');
|
||||
globalThis.KEYCLOAK_URL = kcOverride
|
||||
? kcOverride.replace(/\/$/, '')
|
||||
: 'http://' + window.location.hostname + ':8180';
|
||||
: (kcFromCaddy && !kcFromCaddy.startsWith('{{')
|
||||
? kcFromCaddy.replace(/\/$/, '')
|
||||
: 'http://' + window.location.hostname + ':8180');
|
||||
|
||||
} catch (e) {
|
||||
globalThis.API_BASE_URL = 'http://localhost:8081';
|
||||
|
||||
Reference in New Issue
Block a user