解决跨域问题
1.解决flask跨域问题
pip install flask-cors
from flask_cors import CORS
CORS(app, resources=r'/*')
2.如果使用nginx代理,无需使用方法1,解决nginx跨域
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'username,appname,signature,timestamp,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,token';
include uwsgi_params;
uwsgi_pass 127.0.0.1:8630;
}
把上面配置复制,替换nginx的location配置即可。

浙公网安备 33010602011771号