asp.netcore api两种方式可以设置静态资源跨域,ngxinx代理可以设置,startup配置文件中也可以设置
以下是nginx的静态资源cors跨域设置方法
server {
listen 80;
server_name xxx.domain.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
location / {
proxy_next_upstream http_502 http_504 error timeout invalid_header ;
proxy_pass http://127.0.0.1:5030; ;
}
location /images {
proxy_next_upstream http_502 http_504 error timeout invalid_header ;
proxy_pass http://127.0.0.1:5030/images; ;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' '*';
add_header 'Access-Control-Allow-Credentials' "true";
add_header Access-Control-Allow-Headers X-Requested-With;
}
}