【发布时间】:2022-12-20 01:24:03
【问题描述】:
我在前端使用 sveltekit 版本 .428,在后端使用节点邮件程序。邮寄者会做两件事,发送联系我们的电子邮件和忘记密码的电子邮件。在开发中它会同时执行这两种操作,而在生产中它只会发送联系我们的电子邮件。每当我尝试将客户端电子邮件发送给浏览器日志Failed to load resource: net::ERR_EMPTY_RESPONSE 的邮件程序时,我已经使用 docker 作为管理系统部署在我自己的服务器上。
这是我的帖子请求
async forgotPassword(userEmail: string): Promise<void> {
try {
const url: string = emailUrl + "/forgot-new";
const email: { email: string } = { email: userEmail };
const resp = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(email),
});
if (!resp.ok) {
const data = await resp.json();
throw data.msg;
}
} catch (err) {
throw err;
}
}
这是在我的 nodejs 应用程序中
app.post(`/eid/${version}/forgot-new`,jsonParser, async function (req, res) {
try{
const email = req.body.email;
const user_id = await userRepository.checkIfEmailExists(email)
const token = crypto.randomBytes(36).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '');
const exp_date = new Date();
//1000*60*5 => 5 min
exp_date.setTime(exp_date.getTime() + 1000 * 60 * 5);
const dateFormatted = exp_date.getFullYear() + "-" +
(exp_date.getMonth() + 1) + "-" + exp_date.getDate() +
" " + ("00" + exp_date.getHours()).slice(-2) +
":" +
("00" + exp_date.getMinutes()).slice(-2) + ":" +
("00" + exp_date.getSeconds()).slice(-2);
await userRepository.createValidationCode(user_id, token, dateFormatted)
await mailer.forgotPassword(email, token)
}
catch(err){
throw err
}
})
我试过更改端口号,我试过控制台在浏览器中记录信息(我得到了相同的错误代码),我试过切换浏览器(我得到了相同的错误代码)。我到处寻找可能导致它的原因,我得到的只是它是由谷歌错误引起的,他们建议我清空我的缓存,刷新我的 IP 和我执行的其他一些事情,然后没有运气。
【问题讨论】:
标签: javascript node.js docker google-chrome sveltekit