我有一台运行在heroku(https://resolvelogobackend.herokuapp.com/)上的服务器,而前端运行在netlify(https://resolvelogo.netlify.app/)上
当我尝试在本地发送电子邮件时,将发送电子邮件。当我通过访问前端URL发送时,显示已成功发送电子邮件,但未发送电子邮件。 可能会发生什么?
backend / routes.js
SELECT 10 * FLOOR(id / 10) , AVG(speed), MIN( [from] ) , MAX( [to])
FROM dbo.Thous_Data
GROUP BY 10 * FLOOR(id / 10);
frontend / services / api.js
routes.post("/api/sendMail", (request, response, next) => {
let transporter = nodemailer.createTransport({
service: "gmail",
host: "smtp.gmail.com",
auth: {
user: "************@gmail.com",
pass: "************",
},
});
const message = {
from: request.body.email,
to: "***********@gmail.com",
subject: request.body.subject,
html: `
<h3><strong>Nome:</strong> ${request.body.name}</h3>
<h4><strong>Whatsapp:</strong> ${request.body.phone}</h4>
<p>${request.body.message}</p>
`,
};
transporter.sendMail(message, (error, info) => {
if (error) {
console.log(`Falha no envio. Erro: ${error}`);
}
return response.status(200).send("E-mail enviado com sucesso.");
});
});
frontend / .env
import axios from "axios";
const api = axios.create({
baseURL: process.env.REACT_APP_API_URL,
});
export default api;
Netlify中的环境变量
REACT_APP_API_URL="https://localhost:3001"