feat(infra): single-file toggle between apps-profile dev modes #265
Reference in New Issue
Block a user
Delete Branch "feat/compose-mode-switching"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Make the toggle between the two
apps-profile access modes —localhost(VSCode Remote-SSH port forwarding) and HTTPS hostname (apf-portal.dev-XX.localvia the mkcert team CA) — a single-file edit ininfra/local/.env. Today the switch needs touching two files (the BFF's own.envfor the fourENTRA_*_REDIRECT_URI, plusinfra/local/.envforNX_SERVE_CONFIGURATION), with the extra cost that the BFF.envthen carries mode-specific values and can drift from thelocalhost-friendly defaults that nativenx serve(no Docker) expects.After this PR:
apps/portal-bff/.envstays atlocalhostdefaults always — nativenx serveworks untouched, no mode-aware editing of secrets-bearing files.infra/local/.envis the only file a developer touches to flip between modes. Mode A is the default. Mode B is a five-line block to uncomment.How
The four
ENTRA_*_REDIRECT_URIvalues are added to theportal-bffservice'senvironment:block indev.compose.ymlwith Compose interpolation that defaults tolocalhostand accepts overrides frominfra/local/.env:Compose's
environment:block wins overenv_file:, so the BFF inside the container always sees these —localhostwhen nothing is set ininfra/local/.env, the HTTPS hostname values when Mode B is enabled. The BFF's own.envis irrelevant to the container's redirect URIs in either mode; it remains the canonical source forlocalhost-friendly defaults that nativenx serve(running outside Docker) reads as before.What lands
infra/local/dev.compose.ymlENTRA_*_REDIRECT_URIlines added to theportal-bffservice'senvironment:block with${VAR:-localhost-default}interpolation. Inline comment explains the mode-toggle intent and points atinfra/README.md.infra/local/.env.exampleapps/portal-bff/.env.examplelocalhostregardless and points at the compose-level override ininfra/local/.env.infra/README.mdlocalhostvs hostname" subsection between "Dockerised app dev mode" and "HTTPS dev-server setup". Comparison table + step-by-step for Mode A + pointer to the HTTPS / mkcert subsections that follow for Mode B.Test plan
ENTRA_*_REDIRECT_URIresolve to theirlocalhostdefaults (Mode A).ENTRA_*plusNX_SERVE_CONFIGURATION=httpsset in the environment — the URIs resolve to the HTTPS hostname values (Mode B).infra/local/.envat its.env.exampledefaults../infra/local/dev.sh up apps. Openhttp://localhost:4200/via VSCode Remote-SSH port forwarding. Login succeeds — the BFF receivesENTRA_REDIRECT_URI=http://localhost:3000/api/auth/callback.infra/local/.env(replacingdev-jgwith the actual hostname)../infra/local/dev.sh down && up apps. Openhttps://apf-portal.dev-jg.local:4200/. Login succeeds against the HTTPS URIs.nx serve(no Docker): unchanged — keeps readingapps/portal-bff/.env'slocalhostdefaults; the compose override never runs in this path.Related
feat(spa): opt-in 'https' nx serve config) — provides the SPA-side TLS plumbing the Mode B switch enables.docs(infra): document team mkcert CA on vm-gitlab) — documents the trust root that Mode B relies on.Reduce the apps-profile mode switch (localhost / VSCode tunnel vs HTTPS hostname) to a single file: infra/local/.env. Today the toggle requires editing both apps/portal-bff/.env (the four ENTRA_*_REDIRECT_URI) and infra/local/.env (NX_SERVE_CONFIGURATION). After this PR, apps/portal-bff/.env stays at its localhost defaults regardless — native nx serve outside Docker keeps working untouched — and infra/local/.env carries the entire mode-specific block. - dev.compose.yml portal-bff service: the four ENTRA_*_REDIRECT_URI are added to the environment: block with ${VAR:-localhost-default} interpolation. Compose's environment: wins over env_file:, so the BFF inside the container sees the override when set and the localhost default otherwise. - infra/local/.env.example: the trailing Apps block is restructured as two clearly-labelled profiles (Mode A — Localhost / DEFAULT; Mode B — HTTPS hostname, commented template). - apps/portal-bff/.env.example: comment block above the redirect URI defaults now explains that they stay at localhost regardless and points at the compose-level override in infra/local/.env. - infra/README.md: new "Switching between dev modes — localhost vs hostname" subsection between "Dockerised app dev mode" and "HTTPS dev-server setup" with a comparison table and per-mode step-by-step.