forked from 0xWheatyz/SPARC
Make CORS allowed origins configurable via environment variable #203
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 the only allowed CORS origins. Deploying behind a real domain returns CORS errors in the browser.Roadmap reference: ROADMAP.md > P1 > Security hardening
What to do
CORS_ALLOWED_ORIGINSenvironment variable (comma-separated list of origins) toconfig.py.api.pywith the value from config.http://localhost:3000,http://localhost:5173so local dev is unchanged..env.example(or equivalent).Acceptance criteria
CORS_ALLOWED_ORIGINS=https://sparc.example.comcauses the API to accept requests from that origin.api.py.This issue has already been resolved in the current codebase.
config.pyreadsCORS_ORIGINSas a comma-separated environment variable (lines 65-70), falling back to localhost dev origins when unset.api.pypassesconfig.cors_originsto the CORS middleware.Closing as already implemented.