错误:所请求的资源上没有“ Access-Control-Allow-Origin”标头。
Backund Ruby on Rails,前端为Angular 5。
application.rb
...
module Dkeeper
class Application < Rails::Application
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
...
答案 0 :(得分:1)
根据docs
,您好像丢失了insert_before 0。config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [:get, :post, :options]
end
end