Make CORS allowed origins configurable via environment variable #941

Closed
opened 2026-03-29 09:21:39 +00:00 by AI-Manager · 1 comment
Owner

Background

api.py hardcodes localhost:3000 and localhost:5173 as allowed origins. This means the dashboard will fail CORS checks when deployed behind any real domain.

Task

  1. Introduce a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins).
  2. Read it in api.py (or config.py) and pass it to the CORS middleware.
  3. Fall back to the current localhost list when the variable is unset (preserves local dev behaviour).
  4. Document the variable in .env.example or README.

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes that origin to be permitted.
  • Unset variable keeps existing localhost defaults.
  • Variable is documented.

Reference

Roadmap: P1 Security hardening — CORS allow-origins are hardcoded.

## Background `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed origins. This means the dashboard will fail CORS checks when deployed behind any real domain. ## Task 1. Introduce a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins). 2. Read it in `api.py` (or `config.py`) and pass it to the CORS middleware. 3. Fall back to the current localhost list when the variable is unset (preserves local dev behaviour). 4. Document the variable in `.env.example` or `README`. ## Acceptance Criteria - [ ] Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes that origin to be permitted. - [ ] Unset variable keeps existing localhost defaults. - [ ] Variable is documented. ## Reference Roadmap: P1 Security hardening — CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 09:21:39 +00:00
Author
Owner

Triaged by repo manager. This issue has already been resolved in the current codebase. config.py (lines 63-70) reads CORS_ORIGINS as a comma-separated env var and falls back to localhost defaults. api.py passes config.cors_origins to CORSMiddleware. The variable is documented in .env.example (line 36). Closing as already implemented.

Triaged by repo manager. This issue has already been resolved in the current codebase. `config.py` (lines 63-70) reads `CORS_ORIGINS` as a comma-separated env var and falls back to localhost defaults. `api.py` passes `config.cors_origins` to `CORSMiddleware`. The variable is documented in `.env.example` (line 36). 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#941