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

Press Esc to return to the article
About the author

Prakash Poudel Sharma

Independent product manager & agentic engineering consultant

I'm an independent product manager, founder, and software builder based in Kathmandu. I help teams make product decisions and adopt agentic software development, drawing on over a decade of building software. I write about product thinking, engineering with AI, and hands-on experiments.

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