跨域是一个超级麻烦的事情!
第一种情况
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*'
看到提示有这样的,说明你的reseponse 里面 Access-Control-Allow-Origin
必须是一个确定的网址,而不是直接写一个 * ,
第二种情况,干脆说你没有 Access-Control-Allow-Origin
,这时候需要 flask 手动返回
@app.after_request
def after_request(response):
# response.headers.add('Access-Control-Allow-Origin', 'http://localhost:8080')
response.headers.add('Access-Control-Allow-Credentials', 'true')
response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization,X-Requested-With')
response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
return response