Trailing slash of target URL is missing

Hi,

I created an API and found out that tyk forgets the trailing slash of target url.

Working example:
Target URL: https://www.url.com/API/
Request URL: https://Name.cloud.tyk.io/ProductName/XYZ/2017-11-15
The path in “Log Browser” is: Path: /API/XYZ/2017-11-15
→ the trailing slash is missing, but request works fine

Not working example:
Target URL: https://www.url.com/API/
Request URL: https://Name.cloud.tyk.io/ProductName/
The path in “Log Browser” is: Path: /API
→ does not work. Status Code 301.
It seems so that the rewrite rule at the endpoint cannot be reached (but I’m not sure)

Although I have specified a slash at the end of the path, this slash is “forgotten” in the request.

Supplement:
When I make requests to endpoint in browser or in Postman like this:

 https://www.url.com/API   (without the trailing slash)

Then I get a fine response.

But when I make a request on tyk URL:

 https://Name.cloud.tyk.io/ProductName/

then I get following errors:

  • Firefox Browser: no errors
  • cURL: 301 - Moved permanently
  • Postman: 401 - Unauthorized
  • tyk Error Log: 301

Please note that tyk error log, cURL and Postman show different error codes.

This is a drawback in Tyk Cloud due to how we have to handle API and Org routing. Thi doesn;t happen in Hybrid or on-prem.

O.K. - I was now able to catch this error with a RewriteRule at endpoint.

Hello I have noticed this very same problem when upgrading to gateway version 2.4.1 on premises whereas it was working fine with gateway version 2.3.7

I guess this is not related to tyk cloud at all, but affects all new versions of the gateway.

Could anyone confirm ?

It seems fixed with v2.4.1

Actually, it is not fixed at all with v2.4.1. I Though it was because we rolled back gateways to v2.3.7…
This bug is both strange and very annoying.

Can anyone reproduce it ?

@jmleoni Can you provide an example of what isn’t working?

@Martin
Hi I have the same problem
my config:
“proxy”: {
“listen_path”: “/v2/applications/”,
“target_url”: “http://127.0.0.1:8080/v1/api/applications/”,
“strip_listen_path”: true
}
when my client(postman) send 127.0.0.1:8008/v2/applications/
the server gets : http://127.0.0.1:8080/v1/api/applications

WITHOUT the trailing slash of target url

same config works on v2.3.13 but NOT working in v2.4.0 and up

Thanks
Yuval

301, “Moved Permanently”

The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated. The 301 response from the Web server should always include an alternative URL to which redirection should occur. If it does, a Web browser will immediately retry the alternative URL. This is the best way to ensure that users and search engines are directed to the correct page. The 301 status code means that a page has permanently moved to a new location.