I have a node application which sends a verification email to the user with nodemailer when the user signs up, this worked just fine locally but after deploying the application to aws I get the following error when I try to signup and so it does not send the verification email:
jquery-3.3.1.min.js:2 POST https://www.juliatrefas.net/signup-user 504 (GATEWAY_TIMEOUT)
Why does that happen and how to fix it ?
My server code:
// ********************* SIGNUP *********************************************
app.post('/signup-user', upload.single('avatar'), (req, res) => {
let avatarImagePath;
let token;
let randomNumber;
try {
avatarImagePath = req.file.path.split("public").pop()
token = jwt.sign({
username: req.body.email,
}, "secret", {
expiresIn: 240
});
randomNumber = Math.floor(1000 + Math.random() * 9000);
} catch (e) {
log('e', 'app.post(/signup-user - e - 115 : ' + e)
return res.json({
status: "error"
})
}
user.createUser(req.body, randomNumber, avatarImagePath, (err, jResult) => {
if (err) {
return res.send(jResult)
}
mailer.sendEmail(req.body, token, (err, jResult) => {
if (err) {
return res.send(jResult)
}
console.log(jResult)
return res.send(jResult)
//smsService.sendSms(req.body, randomNumber, res)
})
})
})