Problem:
Even in an empty project with nothing but a single serverless function I cannot get lambda functions to work on the deployed site.
my folder structure is:
serverless
| - .netlify
| - functions
| - hola
| - hola.js
| - netlify.toml
This is hola.js (created from the hello netlify template):
// Docs on event and context https://www.netlify.com/docs/functions/#the-handler-method
const handler = async (event) => {
try {
const subject = event.queryStringParameters.name || "World";
return {
statusCode: 200,
body: JSON.stringify({ message: `Hello ${subject}` }),
// // more keys you can return:
// headers: { "headerName": "headerValue", ... },
// isBase64Encoded: true,
};
} catch (error) {
return { statusCode: 500, body: error.toString() };
}
};
module.exports = { handler };
This is the netlify.toml file:
[build]
functions = "functions"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
When running ntl dev
i have no issues with the function or the redirect.
This project was made from the command line when running ntl deploy --prod
for the first time.
Its only when i deploy using ntl deploy
or ntl deploy --prod
that it completely fails. Attempting to access the function results in a status code of 500.
My netlify project is: https://netnet.netlify.app
The only function is: https://netnet.netlify.app/.netlify/functions/hola
I also have a redirect for the above function (giving the same result though): https://netnet.netlify.app/api/hola
The function logs on the netlify dashboard are blank, containing nothing but a spinning /
.
I’ve spent more than a day trying to debug this but I don’t know to proceed. I’m fairly new to Netlify but even after setting up the most barebones configuration I can think of the most basic functions fail without any logs. Please let me know if you have any questions. Any advice on this issue would be greatly appreciated!