forked from 0xWheatyz/SPARC
Security: make CORS allowed origins configurable via environment variable #1336
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Background
api.pyhardcodes CORS allowed origins tohttp://localhost:3000andhttp://localhost:5173. Any deployment behind a real domain name is blocked unless the code is patched, which is fragile and error-prone.What to do
CORS_ALLOWED_ORIGINSenvironment variable (comma-separated list of origins).api.py(orconfig.py) and pass it to theCORSMiddlewareconfiguration.http://localhost:3000,http://localhost:5173when the variable is unset (preserving local dev behavior)..env.examplewith the new variable and an example value.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses the backend to accept requests from that origin.References
Roadmap: P1 — Security hardening — CORS allow-origins.
Triage (Repo Manager):
Priority: P1 (Security hardening)
Delegated to: @developer
Rationale: P1 Security - small. CORS origins from env var. Simple config extraction in api.py/config.py.
This issue is part of the P1 security hardening batch. All P1 security issues should be addressed before P2/P3 work.
Triaged by repo manager: Already resolved. config.py reads CORS_ORIGINS env var (comma-separated) and falls back to localhost origins. api.py passes config.cors_origins to CORSMiddleware. Closing.