Expressjs redirect

Did anybody face issues while reaching a ‘return res.redirect(somePath)’ under linux/unix based environments???

I’m facing network errors only there, under windows SO, all redirections work great.

-Failing context:
The req uses post method (under a form submitting) and res pretends to reach a route by get method.

Did try almost everything with no luck… :frowning:
If someone knows how to solve this I’ll appreciate your help.


Honestly can’t say much without seeing the code or the error itself but if you have problems with the path ( are you sure that’s the problem? ) you should try the path module ( one of node core modules --> link to path module docs ).
It fit exactly your needs, format path to be supported on every OS ( it builds it in a different way based on the OS to say it better^^)

Hi, thanks for answering!

Will try to explain this much better. I’m following mvc pattern using ejs templating to render different views and compiled HTML does always load.

Also I’m serving some static js & css files under a “public” named folder and that’s were issues under different SO come in, and only when i use res.redirect() i.e, if i reach the very same route by pressing enter under url bar in the browser instead of redirecting from server, I actually do get static files… 🤷

I’ve looked at the link you sent me, I intended to use path.posix regarding I’m writing all my routes as posix but that didn’t work. Another weird thing is that no matters whether I’m serving from linux or windows (using both, path.win32 and path.posix) this redirection thing is always working just on windows.

PS, can’t paste code right now later i will,
However express static is used like this… app.use(express.static(path.posix.join(__dirname, ‘public’)));

Thanks again for responding.