Quantcast
Channel: ¿Nodemailer no funciona en heroku? - Stack Overflow en español
Viewing all articles
Browse latest Browse all 2

¿Nodemailer no funciona en heroku?

$
0
0

Cuando pruebo mi backend en el localhost, funciona correctamente, pero cuando lo despliego en heroku me manda el siguien error:

Access to XMLHttpRequest at'https://chango-tareas-backend.herokuapp.com/api/send-email' fromorigin 'https://localhost:4200' has been blocked by CORS policy: No'Access-Control-Allow-Origin' header is present on the requestedresource.

Esta es la linea de codigo encargarda de enviar correos a traves de nodemailer

//ruta para enviar el correo con nodemailerrouter.post('/send-email', cors(), async (req, res) => {    const { nombre, email, mensaje, url, destino } = req.body;    contentHtml = `<h1>CV solicitante ${nombre}<h1><ul><li>Contactar a: ${email}</li><li>${mensaje}</li></ul><a href="${url}">Click para ver</a>    `;    const transporter = nodemailer.createTransport({        host: 'host_outlock',        port: port,        secure: false,        auth: {            user: 'micorreo@hotmail.com',            pass: 'mipassword'        }    });    try{        const info = await transporter.sendMail({            from: "'ChangoTareas'<abisur_yue@hotmail.com>",            to: `${destino}`,            subject: `Solicitud de registro ${nombre}`,            text: 'Hola guapo :v',            html: contentHtml        });    }catch(err){        next(err);    }    console.log('Message sent', info.messageId);    res.status(200).send({ data: 'Success' });});

En el console log de heroku me arroja las siguientes excepciones

2021-01-19T04:35:32.154277+00:00 app[web.1]: (node:36)UnhandledPromiseRejectionWarning: ReferenceError: next is not defined2021-01-19T04:35:32.154291+00:00 app[web.1]: at/app/src/routes/index.js:128:9 2021-01-19T04:35:32.154292+00:00app[web.1]: at processTicksAndRejections(internal/process/task_queues.js:97:5)2021-01-19T04:35:32.154416+00:00 app[web.1]: (node:36)UnhandledPromiseRejectionWarning: Unhandled promise rejection. Thiserror originated either by throwing inside of an async functionwithout a catch block, or by rejecting a promise which was not handledwith .catch(). To terminate the node process on unhandled promiserejection, use the CLI flag --unhandled-rejections=strict (seehttps://nodejs.org/api/cli.html#cli_unhandled_rejections_mode).(rejection id: 1) 2021-01-19T04:35:32.154521+00:00 app[web.1]:(node:36) [DEP0018] DeprecationWarning: Unhandled promise rejectionsare deprecated. In the future, promise rejections that are not handledwill terminate the Node.js process with a non-zero exit code.2021-01-19T04:35:54.733967+00:00 heroku[router]: at=error code=H12desc="Request timeout" method=POST path="/api/send-email"host=chango-tareas-backend.herokuapp.comrequest_id=ba1f5e44-615f-4545-ab66-254db83c67a1 fwd="187.227.25.218"dyno=web.1 connect=1ms service=30000ms status=503 bytes=0protocol=https


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images