问题:
调试时候跨域访问报:
Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
解决办法:
安装flask_cros
from flask_cors import CORS
CORS(app)
@app.after_request
def af_request(resp):
resp = make_response(resp)
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Methods'] = '*'
resp.headers['Access-Control-Allow-Headers'] = 'Authorization,content-type,token,id'
resp.headers['Access-Control-Request-Headers'] = 'Origin,X-Requested-With,Accept,Authorization'
return resp