Site: US UK AU |
Nexcess Blog

Firefox and Web Fonts on a CDN

November 27, 2013 5 Comments RSS Feed

Broken Web Fonts on a CDN in Firefox

If you’ve tried loading CDN-based Web fonts while browsing with Firefox, you may have noticed they don’t always load. This is because Firefox implemented the W3C Access Control specification and it causes Firefox to reject requests to cross-domain resources. To correct this issue, we need to tell the machine serving those requests to specifically allow cross-domain usage of the resource. To do that, we need to use the Access-Control-Allow-Origin header, I’ll show you how to do this in the last step.

Here are a few other things you should do as well to make sure things will load correctly.

1) The CSS

When adding the font-face links to the font files in your CSS, make sure you set the absolute path to the font files using the full URL to the CDN:

@font-face {

2) MIME types

In the origin servers, add the MIME types for the font files inside .htaccess:

AddType application/    .eot
AddType application/x-font-opentype      .otf
AddType image/svg+xml                    .svg
AddType application/x-font-ttf           .ttf
AddType application/font-woff            .woff

3) Access-Control

Then set up the Access-Control so Firefox behaves and loads your fonts:

<FilesMatch ".(eot|otf|svg|ttf|woff)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"

A wildcard (*) is used in my example, other options are – use your full domain:

Header set Access-Control-Allow-Origin ""

or a sub domain wildcard:

Header set Access-Control-Allow-Origin "*"

This worked for me and I hope it works for you. Please feel free to add your comments, suggestions or questions below.

Posted in: General