我正在使用Font-Awesome-Sass-Rails gem来显示图标字体,它们可以在除Firefox之外的所有浏览器中正确显示。我目前正在使用Cloudfront和Nginx。这是我的CORS配置:
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
有什么想法吗?
答案 0 :(得分:9)
如果上面的答案没有解决任何人的问题,那么这是我的解决方案:
# Cross domain webfont access
location ~* \.(?:ttf|ttc|otf|eot|woff|font.css)$ {
add_header "Access-Control-Allow-Origin" "*";
expires 1M;
access_log off;
add_header Cache-Control "public";
}
答案 1 :(得分:1)
当我遇到同样的问题时,我发现唯一适合我的解决方案是在nginx中设置一个标题。
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
答案 2 :(得分:1)
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
if ($request_filename ~* ^.*?\.(eot)|(ttf)|(woff)|(svg)|(otf)$) {
add_header Access-Control-Allow-Origin *;
}
}