一、先来说下apache的解决办法
在宝塔找到对应的站点的apache配置文件
然后再末尾加入:
<FilesMatch "\.(ttf|otf|eot|woff|svg|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
就可以解决
二、下面来说下ngnix下的解决办法
同理在宝塔找到对应的站点配置文件如图,
然后再底部加入如下代码即可:
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico|ttf|otf|eot|woff|svg|woff2)$ {
#允许跨域请求
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
expires 30d;
access_log off;
}
完结,感谢收看。