Ruby on rails 如何从公用文件夹提供字体允许;“访问控制允许来源”;在轨道上?
我在“公用”文件夹中有字体文件夹。我在css文件中使用的字体路径如下:Ruby on rails 如何从公用文件夹提供字体允许;“访问控制允许来源”;在轨道上?,ruby-on-rails,ruby,fonts,public,Ruby On Rails,Ruby,Fonts,Public,我在“公用”文件夹中有字体文件夹。我在css文件中使用的字体路径如下: https://example.com/fonts/icomoon.eot?2p5wfs 我有一个问题: 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
https://example.com/fonts/icomoon.eot?2p5wfs
我有一个问题:
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.
如果我打开我的chrome“CORS”扩展,它就会工作。如何在不使用此chrome扩展的情况下加载图标?试试:
config.action_dispatch.default_headers = {
'Access-Control-Allow-Origin' => 'https://example.com',
'Access-Control-Request-Method' => %w{GET POST OPTIONS}.join(",")
}
应该在为您的字体提供服务的服务器上启用CORS。