forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #1266
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.pyhardcodeslocalhost:3000andlocalhost:5173as the only CORS allowed origins. This blocks the dashboard from working on any real domain without a code change.Roadmap reference: P1 - Security hardening
What to do
CORS_ORIGINSenvironment variable (comma-separated list).localhost:3000,localhost:5173when the variable is absent.CORS_ORIGINSto.env.examplewith a comment.config.pyto parse and expose this setting.Acceptance criteria
CORS_ORIGINS=https://sparc.example.comresults in only that origin being allowed.api.py.Triage: Already Implemented
This feature is fully implemented in the current codebase on
main:SPARC/config.pyreadsCORS_ORIGINSenv var (lines 65-70), splits on comma, and falls back tolocalhost:3000andlocalhost:5173when unset.SPARC/api.pyusesconfig.cors_originsin the CORS middleware (line 230).docker-compose.ymlpassesCORS_ORIGINSvia${CORS_ORIGINS:-}..env.exampledocuments the variable.All acceptance criteria are met. Closing as completed.