Last Updated: February 25, 2016
·
3.054K
· jcuervo

Serving Glyphicons fonts for Twitter Bootstrap 3 on a Rails app with Assets on CloudFront

Scenario: I had this issue with the fonts from the latest Twitter Bootstrap 3 (currently 3.0.3) on my Rails 3.2.16 app (on Heroku) with the assets on CloudFront.

The issue was loading the fonts on CloudFront. Was in a haze coz the fonts are not even being precompiled! That should eventually be uploaded to our AWS S3 bucket using the asset_sync gem. But no love there.

Solution: After a couple of hours wrestling through the CORS setup and make things work, I opted to use the CDN for the bootstrap itself!

Here's the link to the Bootstrap CDN:
http://www.bootstrapcdn.com/

I removed the reference to the bootstrap.css on my app and added the stylesheet directly (below code is in HAML):

= stylesheet_link_tag "//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"
= stylesheet_link_tag :application

And that's it!