Make CORS allowed origins configurable via environment variable #1266

Closed
opened 2026-03-30 09:21:59 +00:00 by AI-Manager · 1 comment
Owner

Context

api.py hardcodes localhost:3000 and localhost:5173 as the only CORS allowed origins. This blocks the dashboard from working on any real domain without a code change.

Roadmap reference: P1 - Security hardening

What to do

  • Read allowed origins from a CORS_ORIGINS environment variable (comma-separated list).
  • Fall back to localhost:3000,localhost:5173 when the variable is absent.
  • Add CORS_ORIGINS to .env.example with a comment.
  • Update config.py to parse and expose this setting.

Acceptance criteria

  • Setting CORS_ORIGINS=https://sparc.example.com results in only that origin being allowed.
  • Omitting the variable keeps existing local-dev defaults.
  • No origins are hardcoded in api.py.
## Context `api.py` hardcodes `localhost:3000` and `localhost:5173` as the only CORS allowed origins. This blocks the dashboard from working on any real domain without a code change. Roadmap reference: P1 - Security hardening ## What to do - Read allowed origins from a `CORS_ORIGINS` environment variable (comma-separated list). - Fall back to `localhost:3000,localhost:5173` when the variable is absent. - Add `CORS_ORIGINS` to `.env.example` with a comment. - Update `config.py` to parse and expose this setting. ## Acceptance criteria - Setting `CORS_ORIGINS=https://sparc.example.com` results in only that origin being allowed. - Omitting the variable keeps existing local-dev defaults. - No origins are hardcoded in `api.py`.
AI-Manager added the P1agent-readysmallsecurityconfig labels 2026-03-30 09:21:59 +00:00
Author
Owner

Triage: Already Implemented

This feature is fully implemented in the current codebase on main:

  • SPARC/config.py reads CORS_ORIGINS env var (lines 65-70), splits on comma, and falls back to localhost:3000 and localhost:5173 when unset.
  • SPARC/api.py uses config.cors_origins in the CORS middleware (line 230).
  • docker-compose.yml passes CORS_ORIGINS via ${CORS_ORIGINS:-}.
  • .env.example documents the variable.

All acceptance criteria are met. Closing as completed.

## Triage: Already Implemented This feature is fully implemented in the current codebase on `main`: - `SPARC/config.py` reads `CORS_ORIGINS` env var (lines 65-70), splits on comma, and falls back to `localhost:3000` and `localhost:5173` when unset. - `SPARC/api.py` uses `config.cors_origins` in the CORS middleware (line 230). - `docker-compose.yml` passes `CORS_ORIGINS` via `${CORS_ORIGINS:-}`. - `.env.example` documents the variable. All acceptance criteria are met. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1266