【问题标题】:GWT Font-awesome not properly displaying on FirefoxGWT Font-awesome 无法在 Firefox 上正确显示
【发布时间】:2014-02-20 00:31:29
【问题描述】:

我无法让 font-awesome 在 Firefox 中正确显示,即使在 localhost 中也是如此。我收到了一个跨域错误,正是here 报告的内容。

解决这个问题的方法是在.htaccess中或者直接在apache config中添加以下内容:

<FilesMatch "\.(ttf|otf|eot|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>

但我在 Google App Engine 中托管我的应用程序,那么如何在 GAE 中设置 Access-Control-Allow-Origin?

【问题讨论】:

    标签: google-app-engine firefox cross-domain font-awesome


    【解决方案1】:

    如果您使用的是 Java,请编辑您的 appengine-web.xml 文件以包含类似的内容

    <static-files>
      <include path="/my_static-files" >
        <http-header name="Access-Control-Allow-Origin" value="*" />
      </include>
    </static-files>
    

    或者避免使用@mabn 指出的value=* 带来的潜在安全问题。

    <static-files>
      <include path="/my_static-files" >
        <http-header name="Access-Control-Allow-Origin" value="http://example.org" />
      </include>
    </static-files>
    

    如果您使用的是 Python,请编辑您的 app.yaml 文件以包含类似的内容

    - url: /images
      static_dir: static/images
      http_headers:
        Access-Control-Allow-Origin: *
    

    请参阅 Java app configurationPython app configuration 了解更多详细信息以及如何使其更适合您的配置。

    【讨论】:

    • 添加此标头会产生安全问题。不要这样做。或者至少指定主机名而不是“*”
    • @mabn 你为什么不直接编辑答案而不是反对答案?此外,这对于这个特定问题是正确的。问题是如何将 Access-Control-Allow-Origin 设置为“*”。我将编辑以考虑您的安全说明。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 2018-10-18
    • 2020-01-08
    • 1970-01-01
    • 2013-03-22
    相关资源
    最近更新 更多