python
network_error
ai_generated
true
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
ID: python/fastapi-cors-preflight-credentials
80%Fix Rate
88%Confidence
0Evidence
2024-09-21First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 0.100.x | active | — | — | — |
| 0.110.x | active | — | — | — |
Root Cause
CORSMiddleware configured with allow_origins=['*'] and allow_credentials=True simultaneously.
generic中文
CORSMiddleware同时配置了allow_origins=['*']和allow_credentials=True。
Workarounds
-
95% success
app.add_middleware(CORSMiddleware, allow_origins=['https://app.example.com'], allow_credentials=True)
-
92% success
app.add_middleware(CORSMiddleware, allow_origin_regex=r'https://.*\.example\.com', allow_credentials=True)
Dead Ends
Common approaches that don't work:
-
70% fail
Breaks cookie/auth flows that require credentials.
-
85% fail
Browsers still enforce the CORS check client-side.