一、nginx服务器解决方法

服务器使用的是 Nginx,要在响应的头部添加 Access-Control-Allow-Origin 字段,添加方法是用 add_header 指令:

配置例子:

复制代码 代码如下:

location /assets/ {

    gzip_static on;

    expires max;

    add_header Cache-Control public;

    add_header Access-Control-Allow-Origin *;

}

二、apache服务器解决方法

font Awesome (firefox无法显示 火狐无法显示)Cross domain (跨域问题) 

The problem

It seems that, for security reasons, Firefox simply don’t allow you to use by default a font that is not hosted on your domain, not even on your subdomain. The CDN based websites can be also affected in this case.

The solution

After some investigations, I found out the workaround: set a Access-Control-Allow-Origin header to the font.

复制代码 代码如下:

<FilesMatch “\.(ttf|otf|eot|woff)$”>

  <IfModule mod_headers.c>

    Header set Access-Control-Allow-Origin “*”

  </IfModule>

</FilesMatch>

Also, if you are using nginx as your webserver you will need to include the code below in your virtual host file:


复制代码 代码如下:

location ~* \.(eot|otf|ttf|woff)$ {

    add_header Access-Control-Allow-Origin *;

}

您可能感兴趣的文章:

声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。