我在“public”文件夹中有fonts文件夹。我在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 allowed access.
如果我打开我的chrome“CORS”扩展程序,它会起作用。如何在不使用此Chrome扩展程序的情况下加载图标?
答案 0 :(得分:0)
尝试:
config.action_dispatch.default_headers = {
'Access-Control-Allow-Origin' => 'https://example.com',
'Access-Control-Request-Method' => %w{GET POST OPTIONS}.join(",")
}