Frontend Runtime Environment Config¶
Motivation¶
A quick frontend deployment built the Vite bundle without VITE_AZURE_CLIENT_ID, causing the deployed app to show Setup Required even though the API sidecar had the correct Entra App Registration settings.
User-facing change¶
The SPA now reads /runtime-config.js before bootstrapping. The frontend sidecar generates that file at container startup from server environment variables, so a code-only frontend rebuild no longer has to bake every auth value into the static JavaScript bundle.
API / IaC diff summary¶
- Added
web/entrypoint.sh, which writes/usr/share/nginx/html/runtime-config.jsfromVITE_*env vars, falling back toAPI_CLIENT_IDandAZURE_TENANT_IDwhere appropriate. - Added
web/public/runtime-config.jsas an empty local-development default. - Updated auth/API config readers to prefer runtime config over build-time
import.meta.env. - Added frontend sidecar auth/runtime env vars to
infra/modules/containerAppControl.bicep. - Updated
scripts/dev/quick-deploy.shto load.env,web/.env.local, andazd env, pass frontend build args, set frontend Container App env vars, show ACR build logs, avoid blocking indefinitely onazd env get-values, and restore ACR public access immediately after builds.
Validation evidence¶
bash -n scripts/dev/quick-deploy.sh web/entrypoint.sh-> passed.cd web && npm run build-> passed.- Touched-file ESLint -> passed.
az bicep build --file infra/modules/containerAppControl.bicep --stdout-> passed.- Deployed frontend image
acrelbnm5virmqrdi5c.azurecr.io/elb-frontend:runtime-env-fix-20260518to Container App revisionca-elb-control--0000052. curl /runtime-config.js-> returnedwindow.__ELB_RUNTIME_CONFIG__withVITE_AZURE_CLIENT_IDpopulated.curl /api/health->200, revisionca-elb-control--0000052.- Browser smoke -> sign-in screen rendered with
Sign in with Microsoft;Setup Requiredno longer rendered. - ACR network posture restored:
publicNetworkAccess=Disabled,defaultAction=Deny.