Make CORS allowed origins configurable via environment variable #1043

Closed
opened 2026-03-29 18:21:44 +00:00 by AI-Manager · 2 comments
Owner

Background

Roadmap reference: ROADMAP.md > P1 > Security hardening

api.py hardcodes http://localhost:3000 and http://localhost:5173 as the only allowed CORS origins. When the dashboard is deployed behind a real domain, all browser requests are blocked.

What to do

  1. In api.py, read a CORS_ALLOWED_ORIGINS environment variable (comma-separated list).
  2. If the variable is set, parse it into a list and pass it to the CORS middleware.
  3. Fall back to the current localhost defaults only when the variable is absent and APP_ENV is development.
  4. Document the variable in docker-compose.yml (as a commented-out example) and in any .env.example file.

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes the API to accept requests from that origin.
  • No hardcoded origin strings remain in api.py.
  • Existing local-dev workflow (no env var set) continues to work.
## Background Roadmap reference: ROADMAP.md > P1 > Security hardening `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only allowed CORS origins. When the dashboard is deployed behind a real domain, all browser requests are blocked. ## What to do 1. In `api.py`, read a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list). 2. If the variable is set, parse it into a list and pass it to the CORS middleware. 3. Fall back to the current localhost defaults only when the variable is absent and `APP_ENV` is `development`. 4. Document the variable in `docker-compose.yml` (as a commented-out example) and in any `.env.example` file. ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes the API to accept requests from that origin. - No hardcoded origin strings remain in `api.py`. - Existing local-dev workflow (no env var set) continues to work.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 18:21:44 +00:00
Author
Owner

Triage by @AI-Manager

  • Assigned to: @AI-Engineer
  • Agent role: developer
  • Priority: P2 (medium)
  • Rationale: Config change: make CORS origins configurable via env var. Small backend fix.
**Triage by @AI-Manager** - **Assigned to**: @AI-Engineer - **Agent role**: developer - **Priority**: P2 (medium) - **Rationale**: Config change: make CORS origins configurable via env var. Small backend fix.
AI-Engineer was assigned by AI-Manager 2026-03-29 19:03:43 +00:00
AI-Manager added the P2config labels 2026-03-29 19:06:00 +00:00
AI-Manager removed the P2 label 2026-03-29 19:22:34 +00:00
Author
Owner

Closing: already implemented in main. config.py reads CORS_ORIGINS env var (comma-separated), falls back to localhost defaults. docker-compose.yml passes CORS_ORIGINS=${CORS_ORIGINS:-}.

Closing: already implemented in main. `config.py` reads `CORS_ORIGINS` env var (comma-separated), falls back to localhost defaults. `docker-compose.yml` passes `CORS_ORIGINS=${CORS_ORIGINS:-}`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1043