forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #850
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
api.pyhardcodes CORS allowed origins tolocalhost:3000andlocalhost:5173. This means the dashboard cannot communicate with the API when deployed behind a real domain.Work to do
CORS_ALLOWED_ORIGINSenvironment variable (comma-separated list of origins) toconfig.py.api.pyto readCORS_ALLOWED_ORIGINSand pass it to the CORS middleware.http://localhost:3000,http://localhost:5173if the variable is unset, preserving existing local dev behavior.docker-compose.ymlto show the new variable as a commented example.README.mdor relevant docs to document the variable.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses that origin to be permitted.api.py.Resolved in codebase.
SPARC/config.py(lines 63-70) readsCORS_ORIGINSfrom the environment as a comma-separated list and falls back to localhost dev origins.SPARC/api.pyusesconfig.cors_originsin the CORS middleware. Closing as implemented.