简体   繁体   English

使用Heroku在Cloudfront上提供字体

[英]Serving Fonts on Cloudfront with Heroku

I'm trying to setup with Cloudfront on Heroku following the instructions here: https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn-with-rails 我正在按照以下说明在Heroku上使用Cloudfront进行设置: https ://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn-with-rails

Cloudfront is serving css and js assets fine, but I can't get the font icons to be served. Cloudfront可以很好地提供CSS和JS资产,但是我无法提供字体图标。 I have my icon font in assets/fonts and I'm loading the fonts in the stylesheet like this: 我在素材资源/字体中有我的图标字体,并且正在这样在样式表中加载字体:

@font-face {
  src: font-url('dripicons.eot');
  ...
}

The Cloudfront url is not getting prefixing with full Cloudfront URL (it's missing the subdomain). Cloudfront网址未以完整的Cloudfront网址作为前缀(缺少子域)。 It looks like this: 看起来像这样:

https://.cloudfront.net/assets/dripicons-9b4649c1936652d1c1c1d18410b16ebd.eot

I tried using the font_assets gem ( https://github.com/rubymaverick/font_assets ), but it didn't fix the issue. 我尝试使用font_assets gem( https://github.com/rubymaverick/font_assets ),但是它不能解决问题。 I'm using Rails 3.2.13. 我正在使用Rails 3.2.13。

I'd really appreciate any input. 我非常感谢您的投入。 Thanks! 谢谢!

If the URL is missing for your font it could be a configuration issue. 如果您的字体缺少URL,则可能是配置问题。 Please, verify that your environment configuration files (in this case the production.rb one) is correctly configured. 请确认您的环境配置文件(在本例中为production.rb )已正确配置。 From the font_assets guide : font_assets指南

config.font_assets.origin = 'http://coffeescript.codeschool.com'

You should probably an adequate origin URL here. 您可能应该在此处输入足够的原始URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM