Reputation: 338
Error: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Backund Ruby on Rails, Frond-end 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
...
Upvotes: 2
Views: 2483
Reputation: 199
Looks like you're missing insert_before 0 according to the docs
config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [:get, :post, :options]
end
end
Upvotes: 1