Yawd website

feb15

Web-font files not showing in Firefox

I know it's been a while since my last post, but here's a quickie I came across today, one might find it useful:

In a typical Django setup you might be serving your static & media files through different sub-domains. For example, our Elorus eInvoicing/cash flow application serves static files through static.elorus.com and the application itself runs on app.elorus.com. On our production server I noticed this strange behavior where all browsers worked as expected, but Firefox failed to load our font files.

After some research I found out that for security reasons Firefox does not load cross-domain font files. To fix this you must set the Access-Control-Allow-Origin header to the server response that servs the font files.

For those of you running nginx, you can achieve this by adding:

location / {
  alias /path/to/collected/files;
  location ~* \.(eot|ttf|woff)$ {
   add_header Access-Control-Allow-Origin *;
  }
}

in your static files' server configuration.

Meta

Published: Feb. 15, 2013
Comments:  
Word Count: 149
Comments powered by Disqus