前端访问Flask的接口,浏览器报错:has been blocked by CORS policy: No 'Access-Control-Allow-Origin' heade
需要将Flask的api接口允许跨域访问,返回的response中,设置headers['Access-Control_Allow_Origin']="*"
样例如下:
response = make_response(jsonify(data))
response.headers['Access-Control-Allow-Origin'] = '*'
# return jsonify(data)
return response