]> git.openstreetmap.org Git - rails.git/blob - config/initializers/cors.rb
Allow cross-origin requests to API
[rails.git] / config / initializers / cors.rb
1 require "rack/cors"
2
3 # Allow any and all cross-origin requests to the API. Allow any origin, and
4 # any headers. Non-browser requests do not have origin or header restrictions,
5 # so browser-requests should be similarly permitted. (Though the API does not
6 # require any custom headers, Ajax frameworks may automatically add headers
7 # such as X-Requested-By to requests.)
8 Rails.configuration.middleware.use Rack::Cors do
9   allow do
10     origins "*"
11     resource "/api/*", :headers => :any, :methods => [:get, :post, :put, :delete]
12   end
13 end