-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Doesn't appear to properly respond to OPTIONS request #18
Comments
get "/cors" do
cross_origin
# ...
end it's tricky to setup an |
Thanks for the fast response! I think I understand the problem now (or I at least understand it substantially better than I did before). I added a brief note to the README about the workaround and made a pull request. |
Added workaround to the README for issue #18
Fixed by #19, thanks @RyanMarcus! |
For the record, I think a better solution is to use Sinatra::MultiRoute like so: require 'sinatra/multi_route'
require 'sinatra/cross_origin'
route :get, :options, '/my_route' do
cross_origin allow_origin: 'http://example.com', allow_methods: [:get]
# return if this is an OPTIONS request
status 204 and return if request.request_method.to_s.match(/^options$/i)
# actual GET request stuff here
body 'hello world'
end |
In order to get CORS requests working with AngularJS, I had to use
sinatra/cross_origin
and add some special code to handleHTTP OPTIONS
requests:I'm not sure if this is an AngularJS specific issue or a problem in general, but it does appear that Firefox often sends an OPTIONS request before doing any kind of cross-origin request.
The text was updated successfully, but these errors were encountered: