I have been successful using fontawesome within a Rails app for sometime.
I recently tried to move my asset distribution to a CDN, but ran into a CORS issue when using Chrome and Firefox.
I have now added the following to production.rb, which appears to have fixed the problem in Chrome.
config.action_dispatch.default_headers.merge!({
'Access-Control-Allow-Origin' => 'path.to.my.app',
'Access-Control-Request-Method' => '*'
})
I have two questions:
How can I ensure this header is only applied to font files (e.g., if I were using a .htaccess file I would do something like
<FilesMatch "\.(ttf|otf|eot|woff|svg)$">
, how to achieve this in Rails, and is this advisable?)The above appears not have resolved the CORS issue in Firefox (at least I am still seeing 'font missing' blank squares in place of fontawesome icons). Does Firefox have special requirements, and if so, what are they?
I've come across many pages about CORS, CDN, Rails and fonts online, but none appear to be relevant to my case (though this may be because I'm not fully understanding the issue). Grateful for any ideas or references.