Solving Cross-origin Issue With Fonts on Nginx Server

less than 1 minute read

​When using Webfonts via @font-face or other CSS3 methods, some browsers like Firefox and IE will refuse to embed the font when it’s coming from a 3rd party URL because it’s a security risk. The solution is very simple, just add a few lines in your nginx.conf file to permanently solve the problem.

location ~ \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
  add_header Access-Control-Allow-Origin "*";
}

Compiled from: how to use cdn with webfonts

Leave a comment