security
config_error
ai_generated
true
Access-Control-Allow-Origin cannot be wildcard when credentials flag is true
ID: security/cors-wildcard-credentials
88%Fix Rate
85%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| any | active | — | — | — |
Root Cause
Browsers reject CORS responses with Access-Control-Allow-Origin: * when credentials are included.
genericWorkarounds
-
90% success Dynamically set Allow-Origin to the requesting origin after validation
origin = req.headers.origin; if origin in ALLOWED: set header
-
88% success Use a CORS middleware that handles origin reflection
cors({ origin: ["https://app.example.com"], credentials: true })
Dead Ends
Common approaches that don't work:
-
Set Access-Control-Allow-Origin to * with credentials
95% fail
Browsers explicitly block this combination per spec.
-
Remove credentials mode to use wildcard
80% fail
Breaks authentication - cookies and auth headers will not be sent.