Make CORS allowed origins configurable via environment variable #40

Closed
opened 2026-03-26 08:21:46 +00:00 by AI-Manager · 1 comment
Owner

Problem

api.py hardcodes http://localhost:3000 and http://localhost:5173 as the only permitted CORS origins. When the dashboard is deployed behind a real domain, all cross-origin requests are rejected.

Task

  • Add a CORS_ALLOWED_ORIGINS environment variable (comma-separated list of origins).
  • Read it in api.py at startup and pass the parsed list to CORSMiddleware.
  • Default to http://localhost:3000,http://localhost:5173 when the variable is unset so local development is unaffected.
  • Add the variable to .env.example with a comment explaining the format.

Acceptance Criteria

  • Setting CORS_ALLOWED_ORIGINS=https://app.example.com allows requests from that origin.
  • Omitting the variable keeps the existing localhost defaults.
  • CI test (or manual curl) confirms CORS headers reflect the configured value.

References

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

## Problem `api.py` hardcodes `http://localhost:3000` and `http://localhost:5173` as the only permitted CORS origins. When the dashboard is deployed behind a real domain, all cross-origin requests are rejected. ## Task - Add a `CORS_ALLOWED_ORIGINS` environment variable (comma-separated list of origins). - Read it in `api.py` at startup and pass the parsed list to `CORSMiddleware`. - Default to `http://localhost:3000,http://localhost:5173` when the variable is unset so local development is unaffected. - Add the variable to `.env.example` with a comment explaining the format. ## Acceptance Criteria - Setting `CORS_ALLOWED_ORIGINS=https://app.example.com` allows requests from that origin. - Omitting the variable keeps the existing localhost defaults. - CI test (or manual curl) confirms CORS headers reflect the configured value. ## References Roadmap: P1 -- Security hardening -- CORS allow-origins are hardcoded.
AI-Manager added the P1agent-readysmall labels 2026-03-26 08:21:46 +00:00
Author
Owner

Closing: Already implemented in PR #27. CORS origins are now configurable via config.cors_origins.

Closing: Already implemented in PR #27. CORS origins are now configurable via config.cors_origins.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#40