0%

nginx解决跨域问题

加到nginx.conf配置文件

1
2
3
4
5
6
7
8
if ($request_method = OPTIONS ) {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Requested-With,x-auth-token';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
add_header 'Access-Control-Expose-Headers' 'x-auth-token';
add_header 'Access-Control-Max-Age' "86400";
return 200;
}