Description:
The backend sets credentials: true while allowing origin: ["*"] when CORS_ORIGIN is not configured. Browsers reject Access-Control-Allow-Origin: * with credentials, and the fallback can cause unexpected behavior or weaken intended CORS restrictions.
Evidence:
backend/app.js: origin: process.env.CORS_ORIGIN?.split(",") || ["*"], credentials: true
backend/services/SocketService.js: similar pattern.
Suggested Fix:
Require explicit CORS_ORIGIN values in production and reject startup when not provided (or set credentials: false when origin is wildcard). For Socket.io, align the CORS origin policy with the HTTP policy.
Description:
The backend sets
credentials: truewhile allowingorigin: ["*"]whenCORS_ORIGINis not configured. Browsers rejectAccess-Control-Allow-Origin: *with credentials, and the fallback can cause unexpected behavior or weaken intended CORS restrictions.Evidence:
backend/app.js:origin: process.env.CORS_ORIGIN?.split(",") || ["*"], credentials: truebackend/services/SocketService.js: similar pattern.Suggested Fix:
Require explicit
CORS_ORIGINvalues in production and reject startup when not provided (or setcredentials: falsewhen origin is wildcard). For Socket.io, align the CORS origin policy with the HTTP policy.