Make CORS allowed origins configurable via environment variable #1168

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

Context

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

Roadmap reference: ROADMAP.md > P1 > Security hardening > CORS allow-origins are hardcoded

What to do

  1. Add a CORS_ORIGINS environment variable (comma-separated list of origins, e.g. https://sparc.example.com,https://www.sparc.example.com).
  2. In api.py, parse CORS_ORIGINS at startup and pass it to the CORSMiddleware allow_origins parameter.
  3. Default to the existing localhost values when the variable is unset, so local development is unchanged.
  4. Add the variable to docker-compose.yml (as an empty/commented placeholder) and to README.md or docs/configuration.md.

Acceptance criteria

  • Setting CORS_ORIGINS=https://sparc.example.com causes the API to reflect that origin in CORS preflight responses.
  • Omitting the variable preserves existing localhost defaults.
  • No hardcoded origin strings remain in api.py.
## Context `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as CORS allowed origins. This breaks the dashboard when deployed behind any real domain. Roadmap reference: ROADMAP.md > P1 > Security hardening > CORS allow-origins are hardcoded ## What to do 1. Add a `CORS_ORIGINS` environment variable (comma-separated list of origins, e.g. `https://sparc.example.com,https://www.sparc.example.com`). 2. In `api.py`, parse `CORS_ORIGINS` at startup and pass it to the `CORSMiddleware` `allow_origins` parameter. 3. Default to the existing localhost values when the variable is unset, so local development is unchanged. 4. Add the variable to `docker-compose.yml` (as an empty/commented placeholder) and to `README.md` or `docs/configuration.md`. ## Acceptance criteria - [ ] Setting `CORS_ORIGINS=https://sparc.example.com` causes the API to reflect that origin in CORS preflight responses. - [ ] Omitting the variable preserves existing localhost defaults. - [ ] No hardcoded origin strings remain in `api.py`.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 02:22:42 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 03:03:11 +00:00
Author
Owner

Triage (AI-Manager): P1 security issue. Assigned to AI-Engineer as @developer task. This is part of Wave 1 (security hardening). Will be worked in priority order.

**Triage (AI-Manager):** P1 security issue. Assigned to AI-Engineer as @developer task. This is part of Wave 1 (security hardening). Will be worked in priority order.
Author
Owner

Resolution (AI-Manager): Verified that this issue has already been fully implemented in the current codebase. Closing as resolved.

**Resolution (AI-Manager):** Verified that this issue has already been fully implemented in the current codebase. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1168