fontawesome无法正常显示
来源:12-4 nginx配置和域名解析

悟空工作室
2018-11-07
配置完nginx后,fontawesome无法正常显示
浏览器中的Console窗口中报如下错误:
(index):1 Access to font at 'http://s.wukongwork.com/emall-fe/dist/resource/fontawesome-webfont.woff2' from origin 'http://www.wukongwork.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to font at 'http://s.wukongwork.com/emall-fe/dist/resource/fontawesome-webfont.woff' from origin 'http://www.wukongwork.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to font at 'http://s.wukongwork.com/emall-fe/dist/resource/fontawesome-webfont.ttf' from origin 'http://www.wukongwork.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
nginx中的s.wukongwork.com.conf中的配置如下:
server {
listen 80;
autoindex off;
server_name s.wukongwork.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
if ( $query_string ~* ".*[;'<>].*" ){
return 404;
}
location ~ /(mmall-fe|admin-fe)/dist/view/* {
deny all;
}
location / {
root /product/frontend/;
expires 7d;
add_header Access-Control-Allow-Origin *;
}
}
nginx中的wukongwork.com.conf中的配置如下:
upstream www.wukongwork.com{
server 127.0.0.1:8080 weight=1;
server 127.0.0.1:9080 weight=1;
}
server {
listen 80;
autoindex on;
server_name wukongwork.com www.wukongwork.com;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
if ( $query_string ~* ".*[;'<>].*" ){
return 404;
}
location = / {
root /product/frontend/emall-fe/dist/view;
index index.html;
}
location ~ .*.html$ {
root /product/frontend/emall-fe/dist/view;
index index.html;
}
location / {
proxy_pass http://www.wukongwork.com/;
}
}
搞了好长时间没开明白是什么原因,这是跨域问题吗?
写回答
1回答
-
nginx 配置的问题,Access-Control-Allow-Origin这个东西没生效
062018-12-06
相似问题