我有一个带有socketIO插件的Flask服务器,这给我一个反应前端提供了CORS问题。
这是我的JS终端中记录的错误
Access to XMLHttpRequest at 'http://localhost:5000/socket.io/?EIO=3&transport=polling&t=Mh7YS7W' from origin 'http://localhost:3000' has been blocked by CORS policy: 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'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
我看看请求的标题
andf从服务器端放置正确的标头以允许CORS
从服务器终端和我的javascript终端返回的请求均带有200
状态代码。
这是我在服务器端的cors配置
app.config['DEFAULT_PARSERS'] = [
'flask.ext.api.parsers.JSONParser',
'flask.ext.api.parsers.URLEncodedParser',
'flask.ext.api.parsers.FormParser',
'flask.ext.api.parsers.MultiPartParser'
]
...
cors = CORS(app, resources={r"/*": {"origins": "*"}})