Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to serve fonts from public folder allowing "Access-Control-Allow-Origin" in rails?

I have fonts folder in "public" folder. I am using font paths in css file like:

https://example.com/fonts/icomoon.eot?2p5wfs

I am having this issue:

from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

It works if I turn on my chrome "CORS" extension. How can I load icons without using this chrome extension?

like image 896
user1943838 Avatar asked Jan 17 '26 19:01

user1943838


1 Answers

Try:

config.action_dispatch.default_headers = {
    'Access-Control-Allow-Origin' => 'https://example.com',
    'Access-Control-Request-Method' => %w{GET POST OPTIONS}.join(",")
  }
like image 157
s1mpl3 Avatar answered Jan 19 '26 07:01

s1mpl3



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!