Urls with 2 // get 404

Trying to get some loose-ends fixed with our Caddy configuration.
We have several IoT devices that can be linked to one another via Caddy reverse proxy.
One option is to remote to an upstream server.
We can do that, but then the api calls for the upstream server have double forward-slashes (//) which cause a 404.
This use to work with our Nginx configuration. I am not sure if Nginx cleaned up the URI or what, but I am hoping there is something similar for Caddy that I have missed.

After remoting using revers proxy, I see this in chrome URL bar:

http://localhost/home-sam/#/live-view

But in devtools, I see this:
image

Is there anything that can help? Some switch that can take care of URL normalization?

Well, everything including and after # is never sent to the server.

What’s happening I bet is your URL has a trailing /, then your scripts append /api/v1 to the end of it.

Whatever code you have which builds your URLs should ensure to strip the trailing / from current URL before appending your API path. Or better, use this JS: new URI(inputUrl).normalize().toString()

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.