Skip to content

Instantly share code, notes, and snippets.

@ndelage
Last active August 29, 2015 14:05
Show Gist options
  • Save ndelage/8572cd50ac83980b788c to your computer and use it in GitHub Desktop.
Save ndelage/8572cd50ac83980b788c to your computer and use it in GitHub Desktop.
Cross Origin Request Headers for Sinatra
# Add the following before filter at the end of the following
# block, found in your backend's config/environment.rb
#
# configure do
# ...
# ...
# [insert before filter here]
# end
before do
headers 'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST']
end
@ndelage
Copy link
Author

ndelage commented Aug 20, 2014

The gist has been updated, removing PUT and DELETE methods. Since those depend on preflight OPTIONS request. I'm looking into this gem (https://github.com/britg/sinatra-cross_origin) for Sinatra to see about enable to the full spectrum of HTTP requests with CORS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment