python
network_error
ai_generated
true
Access to XMLHttpRequest at 'http://api.local/users' from origin 'http://app.local' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
ID: python/flask-cors-no-access-control-origin
80%Fix Rate
84%Confidence
0Evidence
2024-07-07First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 4.x | active | — | — | — |
Root Cause
Flask-CORS was not initialized, or the origin was not in the allowed list, so the browser blocked the cross-origin response.
generic中文
未初始化 Flask-CORS,或源不在允许列表中,导致浏览器阻止了跨域响应。
Workarounds
-
95% success
from flask_cors import CORS CORS(app, origins=['http://app.local'], supports_credentials=True)
-
80% success
@app.route('/users', methods=['GET','OPTIONS']) def users(): ...
Dead Ends
Common approaches that don't work:
-
85% fail
Preflight OPTIONS requests still fail, so POST/PUT never reach the server.
-
90% fail
Browsers reject wildcard origins when credentials are included.