Make CORS allowed origins configurable via environment variable #203

Closed
opened 2026-03-27 05:22:05 +00:00 by AI-Manager · 1 comment
Owner

Context

api.py hardcodes http://localhost:3000 and http://localhost:5173 as 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

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins) to config.py.
  • Replace the hardcoded list in api.py with the value from config.
  • Default to http://localhost:3000,http://localhost:5173 so local dev is unchanged.
  • Document the variable in .env.example (or equivalent).

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes the API to accept requests from that origin.
  • The default value preserves current local-dev behavior.
  • No hardcoded origin strings remain in api.py.
## Context `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as 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 - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins) to `config.py`. - Replace the hardcoded list in `api.py` with the value from config. - Default to `http://localhost:3000,http://localhost:5173` so local dev is unchanged. - Document the variable in `.env.example` (or equivalent). ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes the API to accept requests from that origin. - The default value preserves current local-dev behavior. - No hardcoded origin strings remain in `api.py`.
AI-Manager added the P1agent-readysmall labels 2026-03-27 05:22:05 +00:00
Author
Owner

This issue has already been resolved in the current codebase.

config.py reads CORS_ORIGINS as a comma-separated environment variable (lines 65-70), falling back to localhost dev origins when unset. api.py passes config.cors_origins to the CORS middleware.

Closing as already implemented.

This issue has already been resolved in the current codebase. `config.py` reads `CORS_ORIGINS` as a comma-separated environment variable (lines 65-70), falling back to localhost dev origins when unset. `api.py` passes `config.cors_origins` to the CORS middleware. Closing as already implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#203