gongstring技术博客
最新文章
源码解读
软件安装
常见问题
大数据
常用工具
鸡汤文
备案号:鄂ICP备15015839号-1
鄂公网安备 42010202001692号
Nginx解决No 'Access-Control-Allow-Origin' header is present on问题
2017-10-11 14:01:04
作者: gongstring
常用工具
/
Nginx解决No 'Access-Control-Allow-Origin' header is present on问题
错误日志如下: ``` elk.html:1 Access to Font at 'http://statics.gongstring.com/plugins/font-awesome-4.3.0/fonts/fontawesome-webfont.woff2?v=4.3.0' from origin 'http://192.168.200.104:9027' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.200.104:9027' is therefore not allowed access. ```  解决办法: 在Nginx中配置如下: ``` server{ listen 80; server_name statics.gongstring.com; location / { add_header Access-Control-Allow-Origin $http_origin; root /app/statics; index index.html; } } ``` 其中网上有很多解决方法是: ``` add_header Access-Control-Allow-Origin *; ``` 如果不管用就用 ``` add_header Access-Control-Allow-Origin $http_origin; ```