0

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)
        })
    })
})
Code Worm
  • 313
  • 1
  • 4
  • 16
  • Either your database newer responds of the `mailer.sendEmail` call (can't tell what the "middleware" `upload.single('avatar')` is doing). Have you debugged the problem (what do your logs say)? – Capricorn Jun 17 '18 at 17:34
  • how can I access the logs in aws? – Code Worm Jun 18 '18 at 07:47

0 Answers0