0

I have downloaded font-awesome 4.5.0 and put on my own cdn (cachefly). Then as suggested from font-awesome i used the link to css file like:

<link rel="stylesheet" href="http://mycachefly.cachefly.net/external/font-awesome/4.5.0/css/font-awesome.min.css">

However, i take the following error:

Font from origin 'http://wisa.cachefly.net' has been blocked
from loading by Cross-Origin Resource Sharing policy: 
No 'Access-Control-Allow-Origin' header is present on 
the requested resource. Origin 'http://localhost' is 
therefore not allowed access.

What is wrong here?

ps: i have no .htaccess file. Its a mixed project from extjs and angular

Asqan
  • 4,319
  • 11
  • 61
  • 100

1 Answers1

0

This is happening because you do not have CORS enabled which allows resources to be loaded from another domain other than your origin. Some services enable CORS by default such as fontawesomecdn.

There is also an explanation at the bottom of this page for enabling CORS on your origin server whether you're using Apache or Nginx.

Apache - place in .htaccess file

<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css|css|js|gif|png|jpe?g|svg|svgz|ico|webp)$">
    Header set Access-Control-Allow-Origin "*"
</FilesMatch>

Nginx - place in nginx.conf file

location ~ \.(ttf|ttc|otf|eot|woff|font.css|css|js|gif|png|jpe?g|svg|svgz|ico|webp)$ {
add_header Access-Control-Allow-Origin "*";
}
CodyA
  • 429
  • 3
  • 5