Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 访问字体“;字体url";“来源于原产地”;Url";已阻止CORS错误_Ruby On Rails_Cors - Fatal编程技术网

Ruby on rails 访问字体“;字体url";“来源于原产地”;Url";已阻止CORS错误

Ruby on rails 访问字体“;字体url";“来源于原产地”;Url";已阻止CORS错误,ruby-on-rails,cors,Ruby On Rails,Cors,你好,我仔细看了一下,找不到答案 错误很明显,但解决方案却不是这样 未加载自定义字体。我在assets/fonts/TypoGraphica.eot 以下是错误: font.scss @font-face { font-family:"TypoGraphica"; src: font-url("TypoGraphica.eot?") format("eot"), font-url("TypoGraphica.woff") format("woff"),

你好,我仔细看了一下,找不到答案

错误很明显,但解决方案却不是这样

未加载自定义字体。我在
assets/fonts/TypoGraphica.eot

以下是错误:

font.scss

@font-face {
  font-family:"TypoGraphica";
  src:  font-url("TypoGraphica.eot?") format("eot"),
        font-url("TypoGraphica.woff") format("woff"),
        font-url("TypoGraphica.ttf") format("truetype"),
        font-url("TypoGraphica.svg#TypoGraphica") format("svg");
}

.typographica { font-family: $font-typographica; }
这是我的cors。目前,我允许任何请求:

module Taddar
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Do not swallow errors in after_commit/after_rollback callbacks.
    config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins '*'
        resource '*', headers: :any, methods: [:get, :post, :options]
      end
    end

    config.active_job.queue_adapter = :delayed_job
    config.browserify_rails.commandline_options =
      '-t [ babelify --presets [ env react stage-0 ] --plugins [ syntax-async-functions transform-regenerator ] ]'
  end
end 
模块Taddar
类应用程序

通过将以下内容添加到
assets.rb

Rails.application.config.assets.precompile