forked from 0xWheatyz/SPARC
Make CORS allowed-origins configurable via environment variable #1376
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
Roadmap item: P1 Security hardening — CORS allow-origins are hardcoded
api.pyhardcodeslocalhost:3000andlocalhost:5173as CORS origins. When SPARC is deployed behind a real domain the frontend cannot reach the API, or the origins must be widened to*(insecure).Task
CORS_ORIGINSenvironment variable toconfig.pythat accepts a comma-separated list of origins (e.g.https://sparc.example.com,https://sparc-staging.example.com).["http://localhost:3000", "http://localhost:5173"]when the variable is unset (preserves local-dev behaviour).CORSMiddlewaresetup inapi.pyto read from the config value.docker-compose.ymlwith a commented-outCORS_ORIGINSexample.Acceptance Criteria
CORS_ORIGINS=https://myapp.example.comin the environment causes the API to accept requests only from that origin.CORS_ORIGINSstill allowslocalhost:3000andlocalhost:5173.api.py..env.exampleorREADME.Reference
See ROADMAP.md § P1 Security hardening.
Resolved by PR #27 (merged). CORS origins are now configurable via the
CORS_ORIGINSenvironment variable inconfig.py, with sensible localhost defaults for development.