Chrome net::ERR_EMPTY_RESPONSE尝试在生产中发送忘记密码的电子邮件时

nbysray5  于 2022-12-20  发布在  Go
关注(0)|答案(1)|浏览(399)

我在前端使用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和其他一些事情,我执行了他们所有,没有运气。

bvk5enib

bvk5enib1#

我发现我的问题是当我构建我的Docker文件时环境文件没有被拾取,这已经被改变了,它工作得很好。

相关问题