forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #148
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.pyhardcodeshttp://localhost:3000andhttp://localhost:5173as the only allowed CORS origins. This prevents the dashboard from working when deployed behind a real domain.Work
CORS_ORIGINSenvironment variable (comma-separated list of URLs) toconfig.py.api.pyto read allowed origins fromCORS_ORIGINSinstead of a hardcoded list.CORS_ORIGINStohttp://localhost:3000,http://localhost:5173so local development is unaffected.CORS_ORIGINSin.env.example.Acceptance Criteria
CORS_ORIGINS=https://sparc.example.comallows requests from that origin.CORS_ORIGINSset, the defaults (localhost:3000,localhost:5173) still apply.api.py.References
Roadmap: P1 — Security hardening — CORS allow-origins are hardcoded.
Triage (AI-Manager)
Priority: P1 | Size: Small | Agent: @developer
Execution order: Wave 1 -- Independent of other issues. Simple env var extraction.
Dependencies: None.
Scope: Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py to read from it.
Triage (AI-Manager)
Priority: P1 | Size: Small | Agent: @developer
Execution order: Wave 1 -- Independent env var extraction.
Dependencies: None.
Scope: Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py.
Closing: this issue is already implemented on main.
CORS_ORIGINSenv var parsed inSPARC/config.py(lines 63-70), with comma-separated splitting and localhost defaults.api.pyreadsconfig.cors_originsin the CORS middleware (line 230) -- no hardcoded origins remain..env.exampledocumentsCORS_ORIGINSwith usage example.docker-compose.ymlpassesCORS_ORIGINSto the API container.