forked from 0xWheatyz/SPARC
Security: make CORS allowed origins configurable via environment variable #1310
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.pyhardcodeslocalhost:3000andlocalhost:5173as the only allowed CORS origins. This means the dashboard cannot function when deployed behind a real domain without a code change.What to do
CORS_ALLOWED_ORIGINSenvironment variable (comma-separated list of origins).api.py, parse this variable and pass the result to the CORS middleware..env.examplewith the new variable.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses the API to return that origin inAccess-Control-Allow-Originheaders.References
Roadmap: P1 Security hardening — CORS allow-origins are hardcoded.
Already resolved. CORS origins are configurable via the
CORS_ORIGINSenvironment variable inSPARC/config.py(lines 63-70). The API middleware inapi.pyusesconfig.cors_origins. Tests intests/test_security.py.