Files
HangmanLab.Frontend/BuildConfig.sh
hzhang ba08bba7de fix: valid config.json + content-hashed bundle (cache-bust)
- BuildConfig.sh: ${DEBUG:false} -> ${DEBUG:-false} and normalize to
  true/false. The old syntax produced empty -> invalid config.json
  ("DEBUG": }) when DEBUG was unset, breaking the whole frontend.
- webpack: output [name].[contenthash].js so index.html references a
  unique bundle URL each build; eliminates stale CDN/browser bundle
  after deploys (no manual cache purge needed).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 17:55:16 +01:00

37 lines
1.3 KiB
Bash

#!/bin/sh
BACKEND_HOST="${BACKEND_HOST:-http://localhost:5000}"
FRONTEND_HOST="${FRONTEND_HOST:-http://localhost:80}"
KC_CLIENT_ID="${KC_CLIENT_ID:-labdev}"
KC_HOST="${KC_HOST:-https://login.hangman-lab.top}"
KC_REALM="${KC_REALM:-Hangman-Lab}"
# Note: ${DEBUG:-false} (correct default syntax). The old ${DEBUG:false}
# produced an empty value when DEBUG was unset -> invalid config.json.
DEBUG="${DEBUG:-false}"
# DEBUG is emitted unquoted as a JSON boolean — guarantee it is exactly
# true/false so config.json can never be invalid JSON.
case "$DEBUG" in true|false) ;; *) DEBUG=false ;; esac
rm -f /usr/share/nginx/html/config.js
cat <<EOL > /usr/share/nginx/html/config.json
{
"BACKEND_HOST": "${BACKEND_HOST}",
"FRONTEND_HOST": "${FRONTEND_HOST}",
"KC_CLIENT_ID": "${KC_CLIENT_ID}",
"OIDC_CONFIG": {
"authority": "${KC_HOST}/realms/${KC_REALM}",
"client_id": "${KC_CLIENT_ID}",
"redirect_uri": "${FRONTEND_HOST}/callback",
"post_logout_redirect_uri": "${FRONTEND_HOST}",
"response_type": "code",
"scope": "openid profile email roles",
"popup_redirect_uri": "${FRONTEND_HOST}/popup_callback",
"silent_redirect_uri": "${FRONTEND_HOST}/silent_callback"
},
"DEBUG": ${DEBUG}
}
EOL
exec "$@"