NodeJs+Express Application issue (linux related)
by Ghost-Order from LinuxQuestions.org on (#5NQZR)
Hello, I have a problem with a very basic ecommerce app develop with Nodejs+express that only occurs in linux, in windows this issue doesn't appear.
I have 3 post handlers that:
1. Write information to the hard drive (for example in the case of new admin user creation).
2. And then redirects the user to another endpoint.
In this case for example, the post handler for the creation of a new admin user writes to the hard drive the new user information and then redirects him to /admin/products
Code:router.post('/signup',
async (req, res) => {
const {email, password, passwordConfirmation} = req.body;
const user = await usersRepo.create({ email, password });
req.session.userId = user.id;
res.redirect('/admin/products');
})The post handler works just fine, it even redirects the user to the correct endpoint as you can see in this image https://i.imgur.com/Ypvzw8M.png, the problem is that the get function that handle that request (for /admin/products) is not working, is not even being called.
Code:router.get('/admin/products',
requireAuth,
async (req, res) => {
const products = await productsRepo.getAll();
res.send(productIndexTemplate({products}))
});However the get handler itself works just fine when I type manually the url in the browser, the issue only occurs when the get handler is invoked from a post handler (through a redirection) that writes to the hard drive. I reach to this conclusion because when the post handler doesn't write any information to the hard drive (for example the sign in post handler) the redirected endpoint loads just fine.
Now as I said this only happens in linux, when I tested on windows this whole issue doesn't appear, so I'm guessing my problem is more related to linux itself than to the application. Have you ever experienced this issue?
I have 3 post handlers that:
1. Write information to the hard drive (for example in the case of new admin user creation).
2. And then redirects the user to another endpoint.
In this case for example, the post handler for the creation of a new admin user writes to the hard drive the new user information and then redirects him to /admin/products
Code:router.post('/signup',
async (req, res) => {
const {email, password, passwordConfirmation} = req.body;
const user = await usersRepo.create({ email, password });
req.session.userId = user.id;
res.redirect('/admin/products');
})The post handler works just fine, it even redirects the user to the correct endpoint as you can see in this image https://i.imgur.com/Ypvzw8M.png, the problem is that the get function that handle that request (for /admin/products) is not working, is not even being called.
Code:router.get('/admin/products',
requireAuth,
async (req, res) => {
const products = await productsRepo.getAll();
res.send(productIndexTemplate({products}))
});However the get handler itself works just fine when I type manually the url in the browser, the issue only occurs when the get handler is invoked from a post handler (through a redirection) that writes to the hard drive. I reach to this conclusion because when the post handler doesn't write any information to the hard drive (for example the sign in post handler) the redirected endpoint loads just fine.
Now as I said this only happens in linux, when I tested on windows this whole issue doesn't appear, so I'm guessing my problem is more related to linux itself than to the application. Have you ever experienced this issue?