next.js - Not able to read public file in vercel(server side) - Stack Overflow

I am trying to send mail using nodemailer and want to pass html template to the nodemailer but not able

I am trying to send mail using nodemailer and want to pass html template to the nodemailer but not able to read the file on vecel. But it is working without any issue on my localhost.

    const orderConfirmationTemplatePathForUser = "/public/mailTemplates/orderConfirmationTemplate.html";

    const sourceForUser = (await fs.readFile(process.cwd() + orderConfirmationTemplatePathForUser, 'utf8')).toString();

folder structure(both src and public are at same level)

/src
/public
--/mailTemplates
----/orderConfirmationTemplate.html

Getting the below error only in vercel

[Error: ENOENT: no such file or directory, open '/var/task/public/mailTemplates/orderConfirmationTemplate.html'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/task/public/mailTemplates/orderConfirmationTemplate.html'
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742417376a4440003.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信