// Angular dev-server proxy for portal-shell. // // Lets the SPA call `/api/...` as a SAME-ORIGIN request — the dev // server intercepts it and proxies to the BFF. Two wins: // - the browser no longer pins the BFF to `localhost:3000`, so the // SPA works when accessed from a different host (e.g. `http:// // :4200/` in the ADR-0030 dockerised dev mode, where the // browser may not be on the same machine as the BFF); // - CORS is bypassed entirely in dev (same origin), so the BFF's // `CORS_ALLOWED_ORIGINS` allowlist no longer has to enumerate the // workstation/VM hostnames a developer might use. // // Target resolution: // - native `nx serve` → defaults to http://localhost:3000 // (the BFF on the same machine). // - Compose `apps` profile → BFF_TARGET=http://portal-bff:3000 is // set in dev.compose.yml so the proxy // hits the BFF container by name. // // JS form (not JSON) is deliberate: it is the only Angular-supported // proxy-config form that can read `process.env` at dev-server startup, // which is what makes the Docker / native swap work without rebuilds. const target = process.env['BFF_TARGET'] ?? 'http://localhost:3000'; module.exports = { '/api': { target, secure: false, changeOrigin: true, }, };