Netlify dev - function not found

I need to be able to locally test my lambda functions. When I run Netlify dev, I see that the Functions server is listening on 55616

then when I POST, I see this:

Request from ::1: POST /.netlify/functions/secret
Response with status 404 in 3 ms.

In the Network tab of the console: “Function not found…”

Here’s my netlify.toml

# The following redirect is intended for use with most SPAs that handle
# routing internally.

# Define which paths this specific [[headers]] block will cover.
for = "/*"
  Access-Control-Allow-Origin = "*"
  command = "npm run build"
  functions = "functions/" # netlify dev uses this directory to scaffold and serve your functions
  publish = "dist"

  command = "npm run start"
  port = 8888
  targetPort = 3000
  publish = "dist" 
  autoLaunch = true
  framework = "create-react-app"

I don’t get why Netlify dev can’t find my functions. They worked in production at hungry-noyce-fb652c. What am I missing in Netlify dev?

Hi @NicoleJaneway,

We can’t comment on why that’s happening without seeing your repo or your folder structure. The only reason why this would happen is when you don’t have a file named secret.js in the functions folder (as per your netlify.toml).

Okay, yeah, that’s the fix.

The functions are in netlify/functions/, which is recognized on prod.

I put a copy of the functions into a separate functions/ folder. Now they are recognized in dev.