Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created August 1, 2012 01:52
Show Gist options
  • Select an option

  • Save ajsharp/3222642 to your computer and use it in GitHub Desktop.

Select an option

Save ajsharp/3222642 to your computer and use it in GitHub Desktop.
module Rack
class Promiscuity
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
status, headers, body = @app.call(env)
if env['REQUEST_METHOD'].upcase == 'OPTIONS'
headers.merge!('Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE')
headers.merge!('Access-Control-Allow-Origin' => '*')
headers.merge!('Access-Control-Max-Age' => '1892160000')
end
[status, headers, body]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment