-
Notifications
You must be signed in to change notification settings - Fork 207
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
[Router] Add options
routes when CORS is used
#240
Comments
@fridgerator Kemal and Kemalyst allows for handlers to happen before the router. This is an example of where that comes in handy since you can look for @eliasjpr @elorest What do you think? Should we look at allowing handlers to be added before the pipeline takes hold? |
options
routes when CORS is usedoptions
routes when CORS is used
options
routes when CORS is usedoptions
routes when CORS is used
I consider that a HEAD request should run thru the entire pipeline since a header can be set at the controller action level or after. As per the OPTIONS this needs to be handled by the CORS handler and if the current request is a
We can also create Preflight pipe to separate concerns. |
Tried to add options route as long as developer uses the CORS pipeline. |
@NeverHappened thank you for contributing to this issue. I found your approach viable given the way things are structured. Personally was considering to just white-list any I have made some improvements to the CORS handler here #665 and would like your input and review. :) |
@eliasjpr Cool :) The only issue I think about is how does it work since request first goes through the @route = router.match_by_request(@request) and then if it matches it goes to the pipeline? There are no options route so it will fail. Or didn't I understand something? |
@NeverHappened you are correct. What I mean is that we can add an |
@eliasjpr Great! That's a lot better than my solution. |
@NeverHappened since you authored the initial PR you can take on the suggested approach. WDYT? |
Yes, of course! |
Issue #240 OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default.
Please see the proposed change here https://github.com/amberframework/amber/pull/700/files |
Issue #240 OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default.
Issue #240 OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default.
Issue #240 HTTP Specs for Methos https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default.
Issue #240 HTTP Specs for Methos https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default.
* [Router] Adds OPTIONS and HEAD routes by default Issue #240 HTTP Specs for Methos https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html OPTIONS and HEAD routes should be automatically defined for routes currently developers have to define the OPTIONS route via the option route method. - Removes the add_head method from router - Adds OPTIONS and HEAD routes ass needed via DSL With these changes developers should no longer need to specify the OPTIONS and HEAD routes and will now be defined by default. * Align route line
Considered fixed with #659 #700
To define routes for SPA apps: Amber::Server.configure do |app|
pipeline :web do
# Add CORS pipe,
# for initialization options
# see https://github.com/amberframework/amber/blob/master/src/amber/pipes/cors.cr#L28
plug Amber::Pipe::CORS.new
end
routes :web do
# Define your routes as normal, `get, post, put, patch, delete`
# methods will define a OPTIONS route by default
get "/", HomeController, :static
end
end |
When building sites with SPA's, preflight requests are sent before all requests. Currently the only way to handle this is to create separate
options
routes for each route used and a middleware to immediately return a 200 response:I haven't looked at how other frameworks handle this, but a user shouldn't have to also include options routes when using CORS.
The text was updated successfully, but these errors were encountered: