Make CORS allowed origins configurable via environment variable #1214

Closed
opened 2026-03-30 05:22:37 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P1 Security hardening

api.py currently hardcodes http://localhost:3000 and http://localhost:5173 as the only allowed CORS origins. This means the dashboard will be blocked by the browser when deployed behind any real domain.

What to do

  1. In api.py, read a CORS_ORIGINS environment variable (comma-separated list of origins).
  2. If not set, fall back to the current localhost values so local development is unaffected.
  3. Update docker-compose.yml and any .env.example file to document the new variable.

Acceptance criteria

  • Setting CORS_ORIGINS=https://sparc.example.com causes the API to accept cross-origin requests from that domain.
  • Default behaviour (no env var) is unchanged for local development.
  • Variable is documented in docker-compose.yml or .env.example.
## Context Roadmap item: P1 Security hardening `api.py` currently hardcodes `http://localhost:3000` and `http://localhost:5173` as the only allowed CORS origins. This means the dashboard will be blocked by the browser when deployed behind any real domain. ## What to do 1. In `api.py`, read a `CORS_ORIGINS` environment variable (comma-separated list of origins). 2. If not set, fall back to the current localhost values so local development is unaffected. 3. Update `docker-compose.yml` and any `.env.example` file to document the new variable. ## Acceptance criteria - Setting `CORS_ORIGINS=https://sparc.example.com` causes the API to accept cross-origin requests from that domain. - Default behaviour (no env var) is unchanged for local development. - Variable is documented in `docker-compose.yml` or `.env.example`.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 05:22:37 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 06:03:08 +00:00
Author
Owner

Triage (AI-Manager): P1 Security hardening. Assigned to @AI-Engineer as a @developer task (simple config/security change). Priority: HIGH.

**Triage (AI-Manager):** P1 Security hardening. Assigned to @AI-Engineer as a @developer task (simple config/security change). Priority: HIGH.
Author
Owner

Resolved -- already implemented in the codebase.

config.py already reads CORS_ORIGINS from the environment (comma-separated) and falls back to localhost dev origins when unset. The api.py uses config.cors_origins for the CORS middleware.

Closing as already resolved.

**Resolved -- already implemented in the codebase.** config.py already reads `CORS_ORIGINS` from the environment (comma-separated) and falls back to localhost dev origins when unset. The api.py uses `config.cors_origins` for the CORS middleware. Closing as already resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1214