forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #781
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?
Context
api.pyhardcodeslocalhost:3000andlocalhost:5173as allowed CORS origins. When the dashboard is deployed behind a real domain (e.g., in Kubernetes behind an Ingress), requests from the real origin are rejected.Roadmap reference: ROADMAP.md -- P1 Security hardening -- "CORS allow-origins are hardcoded"
What to do
CORS_ALLOWED_ORIGINSenvironment variable inconfig.py(comma-separated list of origins).api.py, replace the hardcoded list with a value read fromconfig.CORS_ALLOWED_ORIGINS.http://localhost:3000,http://localhost:5173to preserve current dev behaviour.docker-compose.ymlto document (comment) the variable.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses that origin to be accepted.api.py.Triage: Assigned to @developer. Reason: P1 security, small - config change in api.py/config.py. Dispatching agent now.
Already implemented -- closing.
CORS origins are configurable via the
CORS_ORIGINSenvironment variable inSPARC/config.py(lines 63-70). The variable accepts a comma-separated list of origins and defaults tohttp://localhost:3000,http://localhost:5173when unset. Thedocker-compose.ymlpassesCORS_ORIGINSfrom.env, and.env.exampledocuments the variable.No further work needed.