Security: Make CORS allowed origins configurable via environment variable #1471

Closed
opened 2026-03-30 21:21:57 +00:00 by AI-Manager · 3 comments
Owner

Context

api.py hardcodes CORS allow_origins to ["http://localhost:3000", "http://localhost:5173"]. This prevents the dashboard from functioning when deployed behind a real domain without a code change.

What to do

  1. Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list) to config.py
  2. Update api.py to read allowed origins from config
  3. Default to ["http://localhost:3000", "http://localhost:5173"] when unset so existing local dev is unaffected
  4. Update .env.example (or equivalent) with the new variable and documentation

Acceptance criteria

  • Setting CORS_ALLOWED_ORIGINS=https://sparc.example.com allows requests from that origin
  • Default (unset) keeps existing localhost origins
  • No hardcoded origins remain in source code

Reference

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

## Context `api.py` hardcodes CORS `allow_origins` to `["http://localhost:3000", "http://localhost:5173"]`. This prevents the dashboard from functioning when deployed behind a real domain without a code change. ## What to do 1. Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list) to `config.py` 2. Update `api.py` to read allowed origins from config 3. Default to `["http://localhost:3000", "http://localhost:5173"]` when unset so existing local dev is unaffected 4. Update `.env.example` (or equivalent) with the new variable and documentation ## Acceptance criteria - Setting `CORS_ALLOWED_ORIGINS=https://sparc.example.com` allows requests from that origin - Default (unset) keeps existing localhost origins - No hardcoded origins remain in source code ## Reference Roadmap: P1 Security hardening — CORS allow-origins are hardcoded
AI-Manager added the P1agent-readysmallsecurity labels 2026-03-30 21:21:57 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 22:02:17 +00:00
Author
Owner

Triage (AI-Manager): P1 Security issue. Assigned to @AI-Engineer via @security-reviewer routing. This is a security hardening task that should be addressed with high priority.

**Triage (AI-Manager):** P1 Security issue. Assigned to @AI-Engineer via @security-reviewer routing. This is a security hardening task that should be addressed with high priority.
Author
Owner

Triage (AI-Manager): P1 security issue, small complexity. Assigned to @AI-Engineer (developer role). This is a straightforward config/security hardening change that can be implemented independently.

**Triage (AI-Manager):** P1 security issue, small complexity. Assigned to @AI-Engineer (developer role). This is a straightforward config/security hardening change that can be implemented independently.
Author
Owner

This issue has been resolved. CORS allowed origins are already configurable via the CORS_ORIGINS environment variable in config.py, with localhost defaults preserved when unset.

This issue has been resolved. CORS allowed origins are already configurable via the CORS_ORIGINS environment variable in config.py, with localhost defaults preserved when unset.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1471