如何在Firefox中显示Font Awesome图标?

时间:2013-02-26 02:43:15

标签: ruby-on-rails nginx sass font-face amazon-cloudfront

我正在使用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>

有什么想法吗?

3 个答案:

答案 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)

上面的例子不起作用,这很有用。在nginx配置中,将if块放在/ assets / rule

  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 *;
    }
  }