python
network_error
ai_generated
true
Access to fetch at 'http://api.local/x' from origin 'http://web.local' has been blocked by CORS policy: Response to preflight request doesn't pass access control check
ID: python/flask-cors-blocked-preflight
80%Fix Rate
85%Confidence
0Evidence
2024-12-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.x | active | — | — | — |
| 5.x | active | — | — | — |
Root Cause
Flask-CORS not configured for the route, or OPTIONS preflight handled by a catch-all before CORS middleware.
generic中文
Flask-CORS未针对该路由配置,或者OPTIONS预检被CORS中间件之前的catch-all处理。
Workarounds
-
92% success
CORS(app, resources={r'/api/*': {'origins': ['http://web.local']}}, supports_credentials=True) -
90% success
app = Flask(__name__)\nCORS(app)\n# then register blueprints
Dead Ends
Common approaches that don't work:
-
75% fail
Preflight OPTIONS never reaches the view; browser blocks it earlier.
-
70% fail
If credentials used, wildcard origin is rejected by the browser.