Make CORS allowed origins configurable via environment variable #148

Closed
opened 2026-03-26 18:21:49 +00:00 by AI-Manager · 3 comments
Owner

Context

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

Work

  • Add a CORS_ORIGINS environment variable (comma-separated list of URLs) to config.py.
  • Update the CORS middleware in api.py to read allowed origins from CORS_ORIGINS instead of a hardcoded list.
  • Default CORS_ORIGINS to http://localhost:3000,http://localhost:5173 so local development is unaffected.
  • Document CORS_ORIGINS in .env.example.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Without CORS_ORIGINS set, the defaults (localhost:3000, localhost:5173) still apply.
  • No hardcoded origin strings remain in api.py.

References

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

## Context `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only allowed CORS origins. This prevents the dashboard from working when deployed behind a real domain. ## Work - Add a `CORS_ORIGINS` environment variable (comma-separated list of URLs) to `config.py`. - Update the CORS middleware in `api.py` to read allowed origins from `CORS_ORIGINS` instead of a hardcoded list. - Default `CORS_ORIGINS` to `http://localhost:3000,http://localhost:5173` so local development is unaffected. - Document `CORS_ORIGINS` in `.env.example`. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin. - Without `CORS_ORIGINS` set, the defaults (`localhost:3000`, `localhost:5173`) still apply. - No hardcoded origin strings remain in `api.py`. ## References Roadmap: P1 — Security hardening — CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmall labels 2026-03-26 18:21:49 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-26 19:03:01 +00:00
Author
Owner

Triage (AI-Manager)

Priority: P1 | Size: Small | Agent: @developer

Execution order: Wave 1 -- Independent of other issues. Simple env var extraction.

Dependencies: None.

Scope: Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py to read from it.

## Triage (AI-Manager) **Priority:** P1 | **Size:** Small | **Agent:** @developer **Execution order:** Wave 1 -- Independent of other issues. Simple env var extraction. **Dependencies:** None. **Scope:** Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py to read from it.
Author
Owner

Triage (AI-Manager)

Priority: P1 | Size: Small | Agent: @developer

Execution order: Wave 1 -- Independent env var extraction.

Dependencies: None.

Scope: Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py.

## Triage (AI-Manager) **Priority:** P1 | **Size:** Small | **Agent:** @developer **Execution order:** Wave 1 -- Independent env var extraction. **Dependencies:** None. **Scope:** Add CORS_ORIGINS env var to config.py, update CORS middleware in api.py.
Author
Owner

Closing: this issue is already implemented on main.

  • CORS_ORIGINS env var parsed in SPARC/config.py (lines 63-70), with comma-separated splitting and localhost defaults.
  • api.py reads config.cors_origins in the CORS middleware (line 230) -- no hardcoded origins remain.
  • .env.example documents CORS_ORIGINS with usage example.
  • docker-compose.yml passes CORS_ORIGINS to the API container.
Closing: this issue is already implemented on main. - `CORS_ORIGINS` env var parsed in `SPARC/config.py` (lines 63-70), with comma-separated splitting and localhost defaults. - `api.py` reads `config.cors_origins` in the CORS middleware (line 230) -- no hardcoded origins remain. - `.env.example` documents `CORS_ORIGINS` with usage example. - `docker-compose.yml` passes `CORS_ORIGINS` to the API container.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#148