I tried a lot of solutions found on stackoverflow/github for this issue but I can't get it to work.
I'm using font-awesome-rails and I precompile my assets for production. I've set CloudFront for my assets in my production config:
config.action_controller.asset_host = "https://XXXX.cloudfront.net"
When I load a page (from Chrome/Firefox because Safari is OK with CORS) I get this common error message :
Font from origin 'https://XXXX.cloudfront.net' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://example.com' is therefore not allowed access.
I already tried to :
- Add the gem rack-cors and change my config.ru without success
- Set an
after_filter
to set the server headers without success - Create an invalidation on CloudFront for the three fontawesome files without success
A workaround would be to remove the fontawesome gem and use instead:
<%= stylesheet_link_tag "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css", :media => "all" %>
But I'd rather find the issue.
Thanks