如何在公共文件夹中提供字体,允许在rails中使用“Access-Control-Allow-Origin”?

时间:2017-04-07 13:49:22

标签: ruby-on-rails ruby fonts public

我在“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扩展程序的情况下加载图标?

1 个答案:

答案 0 :(得分:0)

尝试:

config.action_dispatch.default_headers = {
    'Access-Control-Allow-Origin' => 'https://example.com',
    'Access-Control-Request-Method' => %w{GET POST OPTIONS}.join(",")
  }
相关问题