Heroku + CDN Cloudfront +字体 - Firefox错误 [英] Heroku + CDN Cloudfront + Fonts - Firefox bugs

查看:184
本文介绍了Heroku + CDN Cloudfront +字体 - Firefox错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我们在CDN Cloudfront上移动了我们的资产。我们注意到,表面在Firefox上断开了。经过几分钟的搜索,这是一个CORS的故事。我们允许使用Cloudfront字段。



application_controller

  after_filter:set_access_control_headers 

def set_access_control_headers
headers ['Access-Control-Allow-Origin'] = CDN_CLOUDFRONT
end

production.rb

  CDN_CLOUDFRONT =http://xxx.cloudfront.net

这个工作非常好,直到昨天。

解决方案

没有找到解决方案。



/ div>

我没有使用Heroku设置,而是AFAIK(如 developer.mozilla.org ),标头 Access-Control-Allow-Origin 应反映域的值消费来自CDN的静态资产。



例如:
对于托管在 http://mydomain.net 并使用 http://wefe342r34r23.cloudfront.net 中的资源



headers ['Access-Control-Allow-Origin'] ='http://mydomain.net'



将允许mydomain.net通过 http://wefe342r34r23.cloudfront.net 访问资产。换句话说,用您网站的域名替换 CDN_CLOUDFRONT 应该可以解决这个问题。



希望这有助于。 p>

PS:我不知道你的设置是如何工作的,直到昨天。 :)



PPS:在您的CDN中添加替代域名(CNAME)将有助于您在需要快速丢弃现有通过 http://xxx.cloudfront.net 公开的分发,并开始使用新分发 http://yyy.cloudfront.net 。如果您正在使用替代域名,例如 http:// cdn,则无需更改应用程序代码库中的任何内容.mydomain.net


Recently we moved our assets on a CDN Cloudfront. We have noticed that the surfaces were broken on Firefox. After a few minutes of searching, it was a story of CORS. We allowed the field Cloudfront.

application_controller:

after_filter :set_access_control_headers

def set_access_control_headers
  headers['Access-Control-Allow-Origin'] = CDN_CLOUDFRONT
end

production.rb:

CDN_CLOUDFRONT = "http://xxx.cloudfront.net"

This worked very well until yesterday. After several searches and reflections, I have not found a solution.

Any idea?

解决方案

I haven't worked with a Heroku setup, but AFAIK (and as illustrated at developer.mozilla.org), the header Access-Control-Allow-Origin should reflect a value of the domain which consumes static assets from the CDN.

E.g.: For a website hosted at http://mydomain.net and consuming assets from http://wefe342r34r23.cloudfront.net

headers['Access-Control-Allow-Origin'] = 'http://mydomain.net'

Will allow mydomain.net to access assets via http://wefe342r34r23.cloudfront.net. In other words, replacing CDN_CLOUDFRONT with your website's domain name should solve the problem.

Hope this helps.

P.S.: I'm not sure how your setup worked until yesterday. :)

P.P.S: Adding Alternate Domain Names (CNAMEs) to your CDN will help you in a scenario wherein you want to quickly discard an existing distribution exposed over http://xxx.cloudfront.net and start using a fresh distribution http://yyy.cloudfront.net. You won't need to change anything in your application codebase if you are using an Alternate Domain Name such as http://cdn.mydomain.net in that case.

这篇关于Heroku + CDN Cloudfront +字体 - Firefox错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆