Devops

Solving Cross-origin Issue With Fonts on Nginx Server

In this post we learn to setup nginx to allow embedding font from 3rd party url in our rails app.

nginxcorsrails
Solving Cross-origin Issue With Fonts on Nginx Server

​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: <a href=https://www.maxcdn.com/one/tutorial/how-to-use-cdn-with-webfonts/ rel=“nofollow” target=“_blank”>how to use cdn with webfonts

About the author

Prakash Poudel Sharma

Engineering Manager · Product Owner · Varicon

Engineering Manager at Varicon, leading the Onboarding squad as Product Owner. Eleven years of building software — first as a programmer, then as a founder, now sharpening the product craft from the inside of a focused team.

Keep reading

More on this

Join the conversation0 comments

What did you take away?

Thoughts, pushback, or a story of your own? Drop a reply below — I read every one.

Comments are powered by Disqus. By posting you agree to theirterms.

0:000:00