Fork me on GitHub

ios 12.3.1 请求接口跨域问题

1. ios12 系统跨域请求,状态码0

 

 

2. 原因:跨域请求options中请求头缺少参数
请求头信息 Access-Control-Request-Headers: accept, content-type, origin

3. nginx反向代理的解决方法:判断是optinos,添加参数Origin,Accept

if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Headers 'Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,Origin,Accept,X-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,tenant';
add_header Access-Control-Allow-Credentials 'true';
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
return 204;
}

 

posted @ 2021-12-07 15:02  思考的大腿  阅读(579)  评论(0编辑  收藏  举报