-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Headers set in before not respected for auto generated method OPTIONS #406
Comments
Good finding. Looking forward to a PR. If you can't figure it out, I'll take a look. Either way, write a spec that fails, that would be helpful. |
I think this may be related to #414, too. |
It also looks like the headers don't get added for errors either. Which has an interesting consequence if raising errors is part of your normal workflow, as in, raise 401 if unauthorized. When the error is raised, it has no Access-Control-Allow-Origin header and instead of your error being returned, it causes this error: Maybe I should open up a new issue for that @dblock? |
@jure => That is probably because you're injecting the CORS middleware inside Grape, try adding it outside Grape in your config.ru like the example in the README. |
Thanks, that works fine. I was following this bit of advice: #170. Serves me right for not RTFM. :) Thanks. |
it could help you |
Ok, who thinks this is resolved and can be closed? |
Already fixed. Test example works as expected. Closed. |
This is useful for CORS (see issue #170)
Example:
The header for the method POST works correctly
but the header for the method OPTION doesn't respect the headers set in the before block.
$ curl -i -X OPTIONS --data "" localhost:9292/ HTTP/1.1 204 No Content Allow: OPTIONS, POST Server: WEBrick/1.3.1 (Ruby/2.0.0/2013-02-24) Date: Wed, 15 May 2013 13:54:45 GMT Connection: Keep-Alive
The culprit seems to be the way this method is added to the route set.
I can try to fix it, but I'd like some pointers on the best way to build that enpoint so it includes the before callbacks.
The text was updated successfully, but these errors were encountered: