forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #638
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 CORS allowed origins. This means the dashboard breaks when deployed behind a real domain.What to do
api.py, replace the hardcoded origins list with a value read from aCORS_ALLOWED_ORIGINSenvironment variablehttps://sparc.example.com,https://admin.example.com)http://localhost:3000,http://localhost:5173for backwards-compatible local developmentconfig.pyto expose this settingCORS_ALLOWED_ORIGINSin.env.exampleAcceptance criteria
CORS_ALLOWED_ORIGINS=https://my.domain.comcauses the API to accept requests from that originClosing as already implemented.
SPARC/config.pyreadsCORS_ORIGINSfrom the environment (comma-separated list) andapi.pypassesconfig.cors_originsto the CORS middleware. Documented in.env.example.