【发布时间】:2019-02-01 15:49:05
【问题描述】:
我在谷歌缓存我的 AMP 页面后遇到问题。我正在使用 rails 5 实现 amp 页面。使用 rake-cors gem 进行跨域。通常页面工作正常,但缓存后显示控制台错误。
错误:
响应中“Access-Control-Allow-Credentials”标头的值为“”,当请求的凭据模式为“包含”时,该值必须为“真”。因此,不允许访问 Origin 'https://www-myurl-in.cdn.ampproject.org'。
config/application.rb
config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'https://www-myurl-in.cdn.ampproject.org'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
end
我不知道我的代码在哪里更改,请帮助我。
【问题讨论】:
-
你可以尝试制作
origins: '*'。 -
是的,但是 google amp 显示错误以包含 URL
-
你可以试试这个吗?
config.middleware.insert_before 0, Rack::Cors do allow do origins 'https://www-myurl-in.cdn.ampproject.org' resource '*', :headers => :any, :methods => [:get, :post, :options], :credentials => true end end -
不,但我的代码有什么不同。
-
我在现有代码中添加了
credentials选项。
标签: ruby-on-rails cors amp-html ruby-on-rails-5.1 rack-cors