5

I'm trying to configure font-awesome for a Rails3 app hosted in Heroku and using CDN Sumo addon (which uses cloudfront CDN).

The problem is that Firefox is not loading the font assets. I think that the problem is the "Access-Control-Allow-Origin" problem in Firefox. But I can't fix it by using font_assets gem or setting CORS policy in Cloudfront (I don't have access to it because I'm using CDN Sumo addon).

Any idea?

Thanks!

user578828
  • 101
  • 6

3 Answers3

5

Make sure that the Access-Control-Allow-Origin Header is set by the server that is hosting your fonts.

You can configure your origin server, if you need to change it, through the CDN Sumo dashboard.

CDN Sumo does not support custom CORS policies at this time.

For reference, these links might be useful:

Setting CORS for rails apps

Firefox and CORS

Heroku / CDN / fonts

Community
  • 1
  • 1
mmay
  • 205
  • 1
  • 9
2

I just discovered the excellent (and free) CDNJS (powered by Cloudflare) that supports CORS out of the box.

For Rails apps, add the font-awesome CSS link tag in your layout files like this:

<%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.min.css", :media => "all" %>

(Of course, if you are using the asset pipeline, ensure that you remove font-awesome from there.)

You can keep using CDN Sumo for the rest of your assets.

premjg
  • 582
  • 5
  • 12
1

I had the same issue with a Rails 3 app on Heroku; Font-Awesome icons were not showing because I was running my assets through Sumo CDN.

There are several replies related to this, one of which is to put an after_filter in your application_controller to set the header value (by freemanoid), but that didn't work for me, and I had to use the custom middleware suggested by Peter Marklund.

Both solutions are posted here under the Rails 3.1 versions: How to set access-control-allow-origin in webrick under rails?

Community
  • 1
  • 1
btsai
  • 89
  • 1
  • 3