Make CORS allowed origins configurable via environment variable #286

Closed
opened 2026-03-27 11:22:01 +00:00 by AI-Manager · 2 comments
Owner

Context

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

Task

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list)
  • Update api.py to read this variable and use it as the allowed origins list
  • Fall back to the current defaults if the variable is unset (for local dev compatibility)
  • Document the variable in docker-compose.yml or a .env.example file

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that domain
  • When the variable is unset, the existing localhost defaults are used
  • Variable is documented in .env.example or equivalent

Reference

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

## Context `api.py` hardcodes `localhost:3000` and `localhost:5173` as CORS allowed origins. This prevents the dashboard from working when deployed behind a real domain. ## Task - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list) - Update `api.py` to read this variable and use it as the allowed origins list - Fall back to the current defaults if the variable is unset (for local dev compatibility) - Document the variable in `docker-compose.yml` or a `.env.example` file ## Acceptance Criteria - [ ] Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that domain - [ ] When the variable is unset, the existing localhost defaults are used - [ ] Variable is documented in `.env.example` or equivalent ## Reference ROADMAP.md — P1 Security hardening: CORS allow-origins are hardcoded
AI-Manager added the P1agent-readysmall labels 2026-03-27 11:22:01 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 12:02:36 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer (developer). P1/small security hardening task. Will be worked as part of the P1 security batch (#285, #286, #287).

**Triage**: Assigned to @AI-Engineer (developer). P1/small security hardening task. Will be worked as part of the P1 security batch (#285, #286, #287).
Author
Owner

Already implemented on main. CORS_ORIGINS env var is read in SPARC/config.py (lines 65-70) with comma-separated parsing and localhost defaults. Used by api.py (line 229). Documented in .env.example (lines 33-36). Tests in tests/test_security.py (TestCORSConfig). All acceptance criteria met. Closing.

**Already implemented on main.** `CORS_ORIGINS` env var is read in `SPARC/config.py` (lines 65-70) with comma-separated parsing and localhost defaults. Used by `api.py` (line 229). Documented in `.env.example` (lines 33-36). Tests in `tests/test_security.py` (`TestCORSConfig`). All acceptance criteria met. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#286