fix(web-app): Caddy .Env-Template-Injection für API_BASE_URL + KEYCLOAK_URL
All checks were successful
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>
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
"apiBaseUrl": "{{env `API_BASE_URL`}}",
|
||||
"keycloakUrl": "{{env `KEYCLOAK_URL`}}"
|
||||
"apiBaseUrl": "{{.Env.API_BASE_URL}}",
|
||||
"keycloakUrl": "{{.Env.KEYCLOAK_URL}}"
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 276 KiB After Width: | Height: | Size: 276 KiB |
|
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 290 KiB |
BIN
docs/ScreenShots/prod-docker-logs-web-app_2026-03-14_11-11.png
Normal file
|
After Width: | Height: | Size: 306 KiB |
BIN
docs/ScreenShots/prod-env_01_2026-03-14_09-54.png
Normal file
|
After Width: | Height: | Size: 84 KiB |
BIN
docs/ScreenShots/prod-env_02_2026-03-14_09-54.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
docs/ScreenShots/prod-env_03_2026-03-14_09-54.png
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
docs/ScreenShots/prod-env_04_2026-03-14_09-54.png
Normal file
|
After Width: | Height: | Size: 77 KiB |
|
After Width: | Height: | Size: 92 KiB |
|
|
@ -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';
|
||||
|
|
|
|||