I have made a Netlify function that runs with submission-created.js every time a form on my page is created.
I got it working locally with Netlify Dev, but I can’t seem to get it working in production.
The function is sending an auto Reply with NodeMailer to the person that filled out the contact form.
I have 2 separate *.handlebars files I use as templates, but I am not sure how to reference these inside the Functions folder?
I have made a subdirectory inside my functions folder named “autoReply”. Here I have placed both the function AND the 2 *.handlebars files. I know that the function is running isolated on AWS - but I was under the impression I could do it this way?
Right now I am referencing the files inside the function with:
const path = require('path');
“path.resolve(__dirname, “…/autoReply/”),”
In production I get this error:
Invoke Error {“errorType”:“Error”,“errorMessage”:“ENOENT: no such file or directory, open ‘/var/task/src/functions/autoReply/mailTemplateDa.handlebars’”,“code”:“ENOENT”,“errno”:-2,“syscall”:“open”,“path”:"/var/task/src/functions/autoReply/mailTemplateDa.handlebars",“stack”:[“Error: ENOENT: no such file or directory, open ‘/var/task/src/functions/autoReply/mailTemplateDa.handlebars’”]}
What is the correct way to reference files on AWS?
I have looked at various other community posts, but am still unsure how to do this correctly?