forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #1497
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.pyhardcodeslocalhost:3000andlocalhost:5173as the only permitted CORS origins. This breaks the dashboard when deployed behind any real domain.What to do
api.py, read a new env varCORS_ALLOWED_ORIGINS(comma-separated list of origins, e.g.https://sparc.example.com,http://localhost:3000).ENVIRONMENT=development.CORS_ALLOWED_ORIGINSis unset, log a warning (do not refuse to start).docker-compose.ymland any.env.exampleto document the new variable.Acceptance criteria
CORS_ALLOWED_ORIGINSenv var when set.env.exampledocuments the variable[Repo Manager] This issue is already resolved.
SPARC/config.pyreadsCORS_ORIGINSfrom the environment (comma-separated), andapi.pypassesconfig.cors_originsto the CORSMiddleware.docker-compose.ymlalso exposes the variable. Closing as complete.