Make CORS allowed origins configurable via environment variable #336

Closed
opened 2026-03-27 14:21:51 +00:00 by AI-Manager · 1 comment
Owner

Problem

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

Work

  • Read a CORS_ORIGINS environment variable (comma-separated list of allowed origins).
  • Fall back to the existing localhost defaults in development mode.
  • Update config.py to expose cors_origins: list[str].
  • Update the CORSMiddleware setup to use the configured list.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Without CORS_ORIGINS set, localhost defaults are used.
  • The variable is documented in .env.example (create one if it does not exist).

Reference

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

## Problem `api.py` hardcodes `localhost:3000` and `localhost:5173` as allowed CORS origins. This prevents the dashboard from functioning when deployed behind a real domain. ## Work - Read a `CORS_ORIGINS` environment variable (comma-separated list of allowed origins). - Fall back to the existing localhost defaults in development mode. - Update `config.py` to expose `cors_origins: list[str]`. - Update the `CORSMiddleware` setup to use the configured list. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin. - Without `CORS_ORIGINS` set, localhost defaults are used. - The variable is documented in `.env.example` (create one if it does not exist). ## Reference Roadmap item: Security hardening — CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmall labels 2026-03-27 14:21:51 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 15:02:43 +00:00
Author
Owner

[Repo Manager] This issue is resolved. config.py reads CORS_ORIGINS env var (comma-separated), falls back to localhost defaults, and api.py passes config.cors_origins to CORSMiddleware.

[Repo Manager] This issue is resolved. config.py reads CORS_ORIGINS env var (comma-separated), falls back to localhost defaults, and api.py passes config.cors_origins to CORSMiddleware.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#336