首页 > iconfont跨域问题。

iconfont跨域问题。

iconfont为什么存在跨域问题?
同样是静态资源为什么js、css、img文件就没有此问题?


如果很难调试出来,就找个 cdn 挂 font 算了吧,比如七牛、又拍云上面的


字体文件好像也没有跨域问题吧


  1. iconfont 没有跨域问题

  2. 你问题没问对,不过我想我知道你的问题是什么

给你的 webserver 添加如下配置(以 nginx 为例)

location ~* \.(eot|otf|ttf|woff|svg)$ {
  add_header  Access-Control-Allow-Origin *;
}

浏览器对字体文件资源进行了【同源策略】的安全和版权考虑,所以字体文件存在跨域问题的,除非设置CORS。

具体可以到 caniuse 查看!

IE, Firefox and later Chrome versions implement the same origin
policy, so any font library served on a different domain from the page
will not be downloaded unless using CORS.

【热门文章】
【热门文章】