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 "*"
</FilesMatch>

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.

Advertisements