nginx配置跨域

不走代码配置跨域
使用nginx配置跨域

配置示例

1
2
3
4
5
6
7
8
9
10
server {
listen 80;
server_name demo.pangxuejun.cn;
root "~/public";
add_header 'Access-Control-Allow-Origin' "*" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Requested-With,authtoken' always;
}

作者:庞学军