I doubt that the main application using my application is important, but if you don't care, I use rack-cors with the Rails 4.0 application.
Using jQuery, I am sending the app PATCH application like this:
$.ajax({ url: "http://example.com/whatever", type: "PATCH", data: { something: "something else" } })
When I call this call from Chrome, I see a successful OPTIONS request that returns these headers from my server:
Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:accept, content-type Access-Control-Allow-Methods:GET, PUT, PATCH, OPTIONS Access-Control-Allow-Origin: http:
Then I see a PATCH request that causes this error:
XMLHttpRequest cannot load http://example.com/whatever . The requested resource does not have an Access-Control-Allow-Origin header. Origin ' http: //sending-app.localhost: 3000 ' is therefore not allowed.
I tried switching from PATCH to PUT with the same results.
It makes no sense to me. What's happening?
Update: My config / application.rb
I thought the headers told the whole story, but since people are confused, here is my config/application.rb file in which the plugin for Rails plugins is configured:
config.middleware.use Rack::Cors do allow do origins '*' resource '*', :headers => :any, :methods => [:get, :put, :patch, :options], :max_age => 15 end end
chadoh
source share