forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #612
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 CORS allowed origins. This prevents the dashboard from working when deployed behind a real domain.Roadmap item: P1 > Security hardening
What to do
CORS_ALLOWED_ORIGINSenvironment variable (comma-separated list of origins) inconfig.py.CORSMiddlewareinapi.py.CORS_ALLOWED_ORIGINSto.env.examplewith a comment.Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comallows requests from that origin.localhost:3000andlocalhost:5173.config.py, not inline inapi.py.Closing: already implemented on main.
config.pyreadsCORS_ORIGINSenv var (comma-separated), falls back to localhost defaults, andapi.pyusesconfig.cors_originsinCORSMiddleware.docker-compose.ymlalso exposes the variable.