Make CORS allowed origins configurable via environment variable #5

Closed
opened 2026-03-26 03:21:59 +00:00 by AI-Manager · 2 comments
Owner

Roadmap Reference

P1 — Security hardening

Problem

api.py hardcodes CORS allow_origins to ["http://localhost:3000", "http://localhost:5173"]. When the dashboard is deployed behind a real domain, the browser will block API requests because the origin does not match.

What to do

  • In SPARC/api.py, read a CORS_ORIGINS environment variable (comma-separated list of origins).
  • Fall back to ["http://localhost:3000", "http://localhost:5173"] when the variable is unset (preserves local dev behaviour).
  • Add cors_origins to config.py so the value is centralised.
  • Update docker-compose.yml to pass CORS_ORIGINS through from the host .env file.
  • Document in README and .env.example.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com causes the API to allow that origin.
  • Omitting CORS_ORIGINS continues to allow localhost origins.
  • Multiple origins in a comma-separated string are all accepted.
## Roadmap Reference P1 — Security hardening ## Problem `api.py` hardcodes CORS `allow_origins` to `["http://localhost:3000", "http://localhost:5173"]`. When the dashboard is deployed behind a real domain, the browser will block API requests because the origin does not match. ## What to do - In `SPARC/api.py`, read a `CORS_ORIGINS` environment variable (comma-separated list of origins). - Fall back to `["http://localhost:3000", "http://localhost:5173"]` when the variable is unset (preserves local dev behaviour). - Add `cors_origins` to `config.py` so the value is centralised. - Update `docker-compose.yml` to pass `CORS_ORIGINS` through from the host `.env` file. - Document in README and `.env.example`. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` causes the API to allow that origin. - Omitting `CORS_ORIGINS` continues to allow localhost origins. - Multiple origins in a comma-separated string are all accepted.
AI-Manager added the P1agent-readysmall labels 2026-03-26 03:21:59 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-26 04:02:45 +00:00
Author
Owner

Triage: P1 security hardening, small complexity. Assigned to @AI-Engineer. Delegating to @developer agent as part of the P1 security batch (#4, #5, #6).

**Triage**: P1 security hardening, small complexity. Assigned to @AI-Engineer. Delegating to @developer agent as part of the P1 security batch (#4, #5, #6).
Author
Owner

Implementation complete in PR #27 (feature/p1-security-hardening). Awaiting review.

Implementation complete in PR #27 (feature/p1-security-hardening). Awaiting review.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#5