Can't access Netlify functions on deploy

Hi all,

I have a Gatsby site which is deployed to Netlify via Gatsby Cloud. I’m having trouble implementing Netlify lambda functions, and to trouble shoot, I added a simple helloWorld.js lambda function in the /functions folder (as specified in my netlify.toml):

exports.handler = async function () {
  return {
    statusCode: 200,
    body: JSON.stringify({ message: "Hello World" })
  };
}

When I visit localhost:8800/.netlify/functions/helloWorld in netlify dev I get the expected JSON response, but when visiting <deploy url>/.netlify/functions/helloWorld I get redirected to the site’s 404 page.

Here is the deploy: https://602dbd02a90c391f160fae6b--studiomass.netlify.app/

Any help greatly appreciated! :face_with_monocle:

Hi, @StudioMASS. I don’t show any functions processed in that deploy. Also, I don’t see netlify.toml file when I download the deploy either. You can download it here:

https://app.netlify.com/sites/studiomass/deploys/602dbd02a90c391f160fae6b

The download deploy button can be seen in the screenshot below:

download-deploy-button-small

So, I do think the issue is almost certainly that the function isn’t being deployed.

That looks like a manual deploy. Did you use the Netlify CLI tool to deploy? If so, do the directory with the function and file “netlify.toml” both exist in the directory you are publishing?

Excellent tip, had a poke around inside and turns out the functions weren’t making their way into the deploy folder. Added them to static/functions and now they are deploying (although not showing up in the Netlify UI). Thanks!