3 # Mark CORS responses as uncacheable as we don't want a browser to
4 # try and reuse a response that had a different origin, even with
5 # revalidation, as the origin check will fail.
7 class Cors < Rack::Cors
9 status, headers, body = super env
10 if headers['Access-Control-Allow-Origin']
11 headers['Cache-Control'] = 'no-cache'
13 [status, headers, body]
18 # Allow any and all cross-origin requests to the API. Allow any origin, and
19 # any headers. Non-browser requests do not have origin or header restrictions,
20 # so browser-requests should be similarly permitted. (Though the API does not
21 # require any custom headers, Ajax frameworks may automatically add headers
22 # such as X-Requested-By to requests.)
23 Rails.configuration.middleware.use OpenStreetMap::Cors do
26 resource "/oauth/*", :headers => :any, :methods => [:get, :post]
27 resource "/api/*", :headers => :any, :methods => [:get, :post, :put, :delete]