`
GhostWolf
  • 浏览: 308387 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

Access-Control-Allow-Origin 跨域问题

 
阅读更多

        今天发现访问了html5页面,报了如下错误:

 

        Font from origin 'http://design.ehaoyao.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://w.ehaoyao.com' is therefore not allowed access. 

 

        听设计说是,字体跨域问题,孤陋寡闻第一次碰到,查了一下还真的有这么一回事。

 

        Access-Control-Allow-Origin是HTML5中定义的一种服务器端返回Response header,用来解决资源(比如字体)的跨域权限问题。它定义了该资源允许被哪个域引用,或者被所有域引用(google字体使用*表示字体资源允许被所有域引用)。

 

        解决方法:

<!--在nginx.conf中配置-->
http {
  ......
  add_header Access-Control-Allow-Origin *;
  add_header Access-Control-Allow-Headers X-Requested-With;
  add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  ......
}

 

         但是有人又说这种安全性不高,不是太懂,参考一下:

         http://www.51testing.com/html/96/215196-829360.html

         http://ju.outofmemory.cn/entry/63586

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics