I noticed that when I have a route and a sub directory of the same name Express / Nodejs will change the URL when visiting that page in the browser.
For example, if I have a route named foo
and then I create a directory in my project named foo
the URL changes from, localhost/foo
to localhost/foo/
.
It is difficult to simply change the directory name or the route.
Is there a way to prevent express from adding the backslash?
Note: when it adds the backslash I’m still able to serve the HTML page but all the references in the page, the CSS, the Javascript, the images, etc all have foo
prepended to their path. I can set a base path to fix this but I’d rather fix it on the server side.