Can only access backend with trailing slash

Hi there,

I’m experimenting with kong in docker (docker kong:1.1) and added some services with routes (for example TheiaIDE and as route /testroute). The thing is, I can only access my backend when I add a trailing slash on the url like http://localhost:8000/testroute/.

When I try this with http://localhost:8000/testroute I simply get a white page and the console shows 404 error. This is bad for my because I want to secure my backend with some userparameters. Anything I forgot adding the services?

I have a setup script here:

https://paste.ubuntu.com/p/gXwt4SKCWr/

Hi,
Welcome to kong nation.
The thing is that you are not really try and route to an API but to TheiaIDE.
When you access to http://localhost:8000/testroute then your browser try and load http://localhost:8000/bundle.js whereas when you access http://localhost:8000/testroute/ then http://localhost:8000/testroute/bundle.js is called.
In the first case, you do not have the corresponding route defined in kong.
In the second case, it uses your route (/testroute) and send the additional path (bundle.js) to your upstream server.

As a side note, looking at your script, note that you can add a route to a service by using the POST /services/service-name/routes syntax
For example:

curl -i -X POST
–url http://localhost:8001/services/service-v1/routes
–data ‘paths[]=/test1’

Hi tr00mb,

thanks for the warm welcome!

So to sum it up, since I’m trying to access a WebApp and not an API, I’ll get those 404 errors since my application is not really aware of this proxy situation and it tries to call it’s further files on standard root path?
In order to fix it (for the first case), I’d have to add a billion of additional routes for each file in the WebApp?

Is there a possible solution for this or should I try my luck with nginx+rewrite+proxy set-ups?

Best Regards

In did the src="./bundle.js" in the home page of TheiaIDE is difficult to handle without a / in your url.

It depends what you want to do in terms of plugins, but testing it with http://localhost:8000/testroute/ (with the trailing /) should work to access all the webapp

Regards
Yohann