CORS issue: Getting error “No 'Access-Control-Allow-Origin' header is present” when it actually is

前端 未结 4 1690
逝去的感伤
逝去的感伤 2021-02-07 14:46

I doubt the backend serving my app is important, but if you care, I\'m using rack-cors with a Rails 4.0 app.

Using jQuery, I send my app a PATCH request lik

4条回答
  •  借酒劲吻你
    2021-02-07 15:51

    You might want to add this to your config/application.rb file:

    #config/application.rb
    config.middleware.use Rack::Cors do
      allow do
        origins '*'
        resource '/*', :headers => :any, :methods => :patch
      end
    end
    

    The resource part is where you define which methods / requests your endpoint can accept!

    Hope this helps

提交回复
热议问题