Make CORS allowed origins configurable via environment variable #781

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

Context

api.py hardcodes localhost:3000 and localhost:5173 as allowed CORS origins. When the dashboard is deployed behind a real domain (e.g., in Kubernetes behind an Ingress), requests from the real origin are rejected.

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

What to do

  1. Introduce a CORS_ALLOWED_ORIGINS environment variable in config.py (comma-separated list of origins).
  2. In api.py, replace the hardcoded list with a value read from config.CORS_ALLOWED_ORIGINS.
  3. Default the variable to http://localhost:3000,http://localhost:5173 to preserve current dev behaviour.
  4. Update docker-compose.yml to document (comment) the variable.
  5. Update any relevant README/env-example file.

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com causes that origin to be accepted.
  • Leaving the variable unset preserves existing localhost defaults.
  • No hardcoded origin strings remain in api.py.
## Context `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed CORS origins. When the dashboard is deployed behind a real domain (e.g., in Kubernetes behind an Ingress), requests from the real origin are rejected. Roadmap reference: ROADMAP.md -- P1 Security hardening -- "CORS allow-origins are hardcoded" ## What to do 1. Introduce a `CORS_ALLOWED_ORIGINS` environment variable in `config.py` (comma-separated list of origins). 2. In `api.py`, replace the hardcoded list with a value read from `config.CORS_ALLOWED_ORIGINS`. 3. Default the variable to `http://localhost:3000,http://localhost:5173` to preserve current dev behaviour. 4. Update `docker-compose.yml` to document (comment) the variable. 5. Update any relevant README/env-example file. ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` causes that origin to be accepted. - Leaving the variable unset preserves existing localhost defaults. - No hardcoded origin strings remain in `api.py`.
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-29 00:21:40 +00:00
Author
Owner

Triage: Assigned to @developer. Reason: P1 security, small - config change in api.py/config.py. Dispatching agent now.

**Triage**: Assigned to @developer. Reason: P1 security, small - config change in api.py/config.py. Dispatching agent now.
Author
Owner

Already implemented -- closing.

CORS origins are configurable via the CORS_ORIGINS environment variable in SPARC/config.py (lines 63-70). The variable accepts a comma-separated list of origins and defaults to http://localhost:3000,http://localhost:5173 when unset. The docker-compose.yml passes CORS_ORIGINS from .env, and .env.example documents the variable.

No further work needed.

**Already implemented -- closing.** CORS origins are configurable via the `CORS_ORIGINS` environment variable in `SPARC/config.py` (lines 63-70). The variable accepts a comma-separated list of origins and defaults to `http://localhost:3000,http://localhost:5173` when unset. The `docker-compose.yml` passes `CORS_ORIGINS` from `.env`, and `.env.example` documents the variable. No further work needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#781