Problem
The current CORS configuration in backend/main.py allows requests from ANY origin with credentials enabled:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # ❌ Allows any website
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
This is a serious security vulnerability. Any malicious website can make authenticated API requests on behalf of logged-in users.
Solution
Restrict CORS to specific allowed origins:
ALLOWED_ORIGINS = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000").split(",")
app.add_middleware(
CORSMiddleware,
allow_origins=ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allow_headers=["Authorization", "Content-Type"],
)
Acceptance Criteria
Files to Modify
backend/main.py
.env.example
backend/.env.example
Problem
The current CORS configuration in
backend/main.pyallows requests from ANY origin with credentials enabled:This is a serious security vulnerability. Any malicious website can make authenticated API requests on behalf of logged-in users.
Solution
Restrict CORS to specific allowed origins:
Acceptance Criteria
allow_origins=["*"]removed.env.examplewithALLOWED_ORIGINSvariableFiles to Modify
backend/main.py.env.examplebackend/.env.example