We serve some web fonts (.woff) from our static assets and I would like to set the correct mime type (application/x-font-woff
). I tried to do this in config/initializers/mime_types.rb
but it had no effect:
Mime::Type.register "application/x-font-woff", :woff
The returned mime type still stayed application/octet-stream
. I even tried to add this line (because it was the only other place in the rails source where I could find the string "woff"
):
Rack::Mime::MIME_TYPES[".woff"] = "application/x-font-woff"
But it still didn't help. How do I properly set the mime type for web fonts?
Until Rack fixes its MIME-type list to a correct woff
, the interim hack is indeed your config/initializers/mime_types.rb
line:
# tell Rack (and Sprockets) about modern font MIME types:
Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'
To have it actually take effect, though, you have to wipe tmp/cache
and restart your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With