静态资源跨域解决方案

Access to font at 'http://static.xxx.com/css/element-ui/fonts/element-icons.woff' from origin 'http://lw.xxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

这是出现问题的现象

nginx静态资源允许跨域访问

在server模块中添加配置:

add_header ‘Access-Control-Allow-Origin' ‘*';
server {
    listen    80;
    add_header 'Access-Control-Allow-Origin' '*';
    location /Roboto/ {
      root  /home/images;
      autoindex on;
    }
  }

通过以上方法配置完后,再次跨域访问静态资源就没有问题了

上一篇:Squid代理


下一篇:Debian 中 allow-hotplug 与 auto 的区别(转)