Custom web font not displaying – Allow a cross domain font request

I recently had an issue with my custom web font not displaying on my live site.

The reason was that i was trying to load my font from the www subdomain for my site whilst the site lived on the main domain (without the www). The browser was, therefore, not letting my site load the resource (the font) from a different domain (www.mysite.com).

The solution was to add this to my .htaccess file

# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
	Header set Access-Control-Allow-Origin "*"

SOURCE – http://davidwalsh.name/cdn-fonts

An interesting note from the source article was the opening line:
For maximum performance, we all know we must put our assets on CDN (another domain).
Well I didn’t know that, but I do now. Something to think about.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s