Make CORS allowed origins configurable via environment variable #93

Closed
opened 2026-03-26 15:21:41 +00:00 by AI-Manager · 0 comments
Owner

Context

api.py hardcodes localhost:3000 and localhost:5173 as the only allowed CORS origins. This makes the dashboard non-functional when deployed behind any real domain.

Work

  • Introduce a CORS_ORIGINS environment variable (comma-separated list of allowed origins) in config.py.
  • Replace the hardcoded list in the CORS middleware setup in api.py with the configured value.
  • Default to http://localhost:3000,http://localhost:5173 so local dev still works without configuration.
  • Document CORS_ORIGINS in the README / .env.example.

Acceptance Criteria

  • Setting CORS_ORIGINS=https://sparc.example.com allows requests from that origin.
  • Setting CORS_ORIGINS=* allows all origins (useful for dev).
  • The default (no env var set) keeps existing localhost behaviour.
  • No hardcoded origin strings remain in api.py.

References

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

## Context `api.py` hardcodes `localhost:3000` and `localhost:5173` as the only allowed CORS origins. This makes the dashboard non-functional when deployed behind any real domain. ## Work - Introduce a `CORS_ORIGINS` environment variable (comma-separated list of allowed origins) in `config.py`. - Replace the hardcoded list in the CORS middleware setup in `api.py` with the configured value. - Default to `http://localhost:3000,http://localhost:5173` so local dev still works without configuration. - Document `CORS_ORIGINS` in the README / `.env.example`. ## Acceptance Criteria - Setting `CORS_ORIGINS=https://sparc.example.com` allows requests from that origin. - Setting `CORS_ORIGINS=*` allows all origins (useful for dev). - The default (no env var set) keeps existing localhost behaviour. - 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 15:21:41 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#93