Make CORS allowed origins configurable via environment variable #638

Closed
opened 2026-03-28 12:21:41 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P1 Security Hardening

api.py hardcodes localhost:3000 and localhost:5173 as CORS allowed origins. This means the dashboard breaks when deployed behind a real domain.

What to do

  • In api.py, replace the hardcoded origins list with a value read from a CORS_ALLOWED_ORIGINS environment variable
  • The variable should accept a comma-separated list of origins (e.g. https://sparc.example.com,https://admin.example.com)
  • Default to http://localhost:3000,http://localhost:5173 for backwards-compatible local development
  • Update config.py to expose this setting
  • Document CORS_ALLOWED_ORIGINS in .env.example

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://my.domain.com causes the API to accept requests from that origin
  • Unset variable falls back to localhost defaults
  • The parsing is robust (strips whitespace, handles empty values gracefully)
## Context Roadmap item: P1 Security Hardening `api.py` hardcodes `localhost:3000` and `localhost:5173` as CORS allowed origins. This means the dashboard breaks when deployed behind a real domain. ## What to do - In `api.py`, replace the hardcoded origins list with a value read from a `CORS_ALLOWED_ORIGINS` environment variable - The variable should accept a comma-separated list of origins (e.g. `https://sparc.example.com,https://admin.example.com`) - Default to `http://localhost:3000,http://localhost:5173` for backwards-compatible local development - Update `config.py` to expose this setting - Document `CORS_ALLOWED_ORIGINS` in `.env.example` ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://my.domain.com` causes the API to accept requests from that origin - Unset variable falls back to localhost defaults - The parsing is robust (strips whitespace, handles empty values gracefully)
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-28 12:21:41 +00:00
Author
Owner

Closing as already implemented. SPARC/config.py reads CORS_ORIGINS from the environment (comma-separated list) and api.py passes config.cors_origins to the CORS middleware. Documented in .env.example.

Closing as already implemented. `SPARC/config.py` reads `CORS_ORIGINS` from the environment (comma-separated list) and `api.py` passes `config.cors_origins` to the CORS middleware. Documented in `.env.example`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#638