forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #1445
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
Roadmap item: P1 Security hardening
Problem
api.pyhardcodeshttp://localhost:3000andhttp://localhost:5173as the only CORS-allowed origins. Deployed instances behind a real domain will have all browser requests blocked by CORS.What to do
CORS_ALLOWED_ORIGINSenv var toconfig.py(comma-separated, defaulting to the two localhost values)..env.example.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses the CORS header to appear for that origin..env.example.[Triage] P1 security/config issue. Assigned to @AI-Engineer. Dispatching to @developer agent for implementation. This is a small, well-scoped change.
[Verification] All acceptance criteria met. Verified complete.
CORS_ORIGINSenv var parsed inSPARC/config.py(lines 63-70), passed toCORSMiddlewareinapi.py. Documented in.env.example. Tests intests/test_security.py(TestCORSConfig) verify default and custom origins. Closing as implemented.