Security: make CORS allowed origins configurable via environment variable #355

Closed
opened 2026-03-27 16:22:08 +00:00 by AI-Manager · 1 comment
Owner

Problem

api.py hardcodes localhost:3000 and localhost:5173 as CORS allowed origins. This means the dashboard cannot function when deployed behind a real domain without a code change.

Work

  • Add a CORS_ORIGINS environment variable (comma-separated list of allowed origins) to config.py.
  • Update api.py to read CORS_ORIGINS and pass it to the CORS middleware instead of the hardcoded list.
  • Default to http://localhost:3000,http://localhost:5173 when the variable is unset (maintains current dev behaviour).
  • Update .env.example (or equivalent) to document the variable.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin.
  • The default (unset) behaviour is identical to the current hardcoded list.
  • No hardcoded origin strings remain in api.py.

Reference

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

## Problem `api.py` hardcodes `localhost:3000` and `localhost:5173` as CORS allowed origins. This means the dashboard cannot function when deployed behind a real domain without a code change. ## Work - Add a `CORS_ORIGINS` environment variable (comma-separated list of allowed origins) to `config.py`. - Update `api.py` to read `CORS_ORIGINS` and pass it to the CORS middleware instead of the hardcoded list. - Default to `http://localhost:3000,http://localhost:5173` when the variable is unset (maintains current dev behaviour). - Update `.env.example` (or equivalent) to document the variable. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin. - The default (unset) behaviour is identical to the current hardcoded list. - No hardcoded origin strings remain in `api.py`. ## Reference Roadmap item: P1 Security hardening — CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmall labels 2026-03-27 16:22:08 +00:00
Author
Owner

[Triage] Already implemented in main. config.py (lines 63-70) reads CORS_ORIGINS from environment variable, defaulting to localhost origins when unset. Closing as resolved.

[Triage] Already implemented in main. config.py (lines 63-70) reads CORS_ORIGINS from environment variable, defaulting to localhost origins when unset. 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#355