Summary
backend/src/main.ts bootstraps CORS as:
app.enableCors({
origin: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization'],
credentials: true,
});
Per the Fetch/CORS spec, Access-Control-Allow-Origin: * cannot be combined with credentialed requests - browsers reject such responses. Depending on how the underlying layer behaves, this means either (a) credentialed browser clients are broken, or (b) origins are effectively reflected, making every site trusted to send cookie/Authorization-bearing requests. Both outcomes are wrong.
Proposal
- Move the allowlist to configuration: read
CORS_ORIGINS (comma-separated) from env via the existing ConfigModule/app.config.ts.
- Pass
origin: <allowlist> and keep credentials: true only when the allowlist is non-wildcard.
- Document the variable in
docs/ENVIRONMENT.md (which already catalogs backend env vars).
Acceptance criteria
Summary
backend/src/main.tsbootstraps CORS as:Per the Fetch/CORS spec,
Access-Control-Allow-Origin: *cannot be combined with credentialed requests - browsers reject such responses. Depending on how the underlying layer behaves, this means either (a) credentialed browser clients are broken, or (b) origins are effectively reflected, making every site trusted to send cookie/Authorization-bearing requests. Both outcomes are wrong.Proposal
CORS_ORIGINS(comma-separated) from env via the existingConfigModule/app.config.ts.origin: <allowlist>and keepcredentials: trueonly when the allowlist is non-wildcard.docs/ENVIRONMENT.md(which already catalogs backend env vars).Acceptance criteria
http://localhost:5173).