-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
trailing slashes appended to requests to root of a configured API #2211
Comments
Hey, Noticed your message on Gitter (I think?) but thanks for the report! Will investigate. |
@thibaultcha yeah, that was me, figured it warranted an issue. Thanks for your help! |
I have the same question. It didn't behave like this in 0.9.8. The extra slash is unexpected. How to avoid that? |
Hi, just came across this issue too. Also looking for a workaround. This is a serious issue because some upstream behave differently with a trailing slash http://foo/bar can be different from http://foo/bar/ in my case http://foo/bar/ return a 404 while http://foo/bar does not. |
Here is what I would propose to handle upstream URLs trailing slashes: Since 0.10.0, we know an API's Now on to the issue at hand: providing a way for the consumer to be able to chose whether the upstream URL will have a trailing slash or not. For this, I believe we can do the following: The decision on whether or not to append a trailing slash to the upstream URI depends on the incoming request URI:
The last row in here seems to be the only way to control whether or not to append a trailing slash to the upstream URI (call from Kong) when the request URI simply is
Explanation: we still ignore trailing slash in This way, whenever the request URI is not |
@thibaultcha thank you for the thorough explanation and prompt reply. I agree that this is the best path forward and provides the most flexibility for the Kong administrator and API clients. |
@thibaultcha thanks a lot for your detailed explanation. My config is very similar to @pklingem 's case:
Then when I send a request According to your table, only the 2nd and 4th rows will append trailing slashes (notice that I don't have trailing slash configured in |
@thibaultcha I have the same question in the version of 0.10x. When I access one of my services like http:// example.com/service.controller through the browser, the browser give me the right data and return the HTTP status code 200 OK, but when I add a slash at the end of that url, that is to say the url is http:// example.com/service.controller/, the browser return the HTTP status code 404 NOT FOUND and I don't receive the right data which I want to get. If I want to get the right data from the service when I access the url, I should not add the slash at the end of that url. when I register an API like
Then access the API by curl:curl -X GET http://kong:8000/test1. |
Hi folks, My configuration is actually the opposite to this, that is, I do need a trailing slash for my backend to work. I wanted to confirm with you folks that I understand this correctly. In 0.9.X, the trailing slash is deleted (at least if strip_request_path is enabled) whereas it is appended in 0.10.0 and 0.10.1. In addition, the way it will be implemented in the future is as @thibaultcha described. Am I right? Many thanks. |
@mgiorgio, correct. I will be looking at this issue and implement this as @thibaultcha suggested above. Is that alright with you? |
@bungle yes, that would be perfect! Thanks! |
@bungle Thanks for your response.We also had the same problem.kong10.x appended slash on upstream url,and kong0.9.x did not act that. When will u release this change? |
@deepshrift, I will keep you updated. I hope soon. |
This fix is just what we need too |
@rodrigo-garcia-engrande, I'm pretty sure we get this to next release, along with #2343. |
Summary
Requests to the root of an API registered with kong 0.10.0 append a trailing slash to the request when it's passed to the upstream API.
Steps To Reproduce
the upstream service will receive a request like so:
Additional Details & Logs
It looks as if this bug existed previously and was fixed at one point, see the comments here and #675
The text was updated successfully, but these errors were encountered: