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

admin2025-03-20  5

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'
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1742417378a212736.html

最新回复(0)