nginx 静态文件支持跨域访问权限

一、原生态      

location ^~ /repurchase-web/ {
          alias /var/www/webapps/repurchase-web/;
        }

 

二、支持跨域      

location ^~ /repurchase-web/ {
          add_header Access-Control-Allow-Origin *;
          add_header Access-Control-Allow-Credentials true;
          alias /var/www/webapps/repurchase-web/;
        }

在中间添加

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;

即可。

posted @ 2017-03-16 13:18  帅丶高高  阅读(4891)  评论(0)    收藏  举报