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;
}
用心写代码,不辜负程序员之名。
原文地址:https://www.cnblogs.com/thinkingthigh/p/15656224.html