Correct URL endpoint for Netlify Functions when using Netlify Dev

Hey folks.

I’ve added a Netlify Function (myfunc), set my functions directory in netlify.toml:

[build]
  publish = "docs/.vuepress/dist"
  command = "vuepress build docs"
  functions = "api"

& I have it working within Netlify Dev (i.e. after running netlify dev, I can curl http://localhost:34567/myfunc & get a response) but when I try to fetch the endpoint from my frontend in local development, I hit issues. When I try to fetch the localhost URL (http://localhost:34567/myfunc) in my frontend, I hit the CORS problem. When I try to fetch the URL as recommended in this guide (/.netlify/api/myfunc), I get a 404.

Any sense of what I’m doing wrong? I looked into netlify-lambda & whether I need it but just got more confused. Any insight here would be appreciated.

Thanks,
Sam

I tried changing the URL I fetch to /.netlify/functions/myfunc as specified in the docs but this also hits a 404. I suspect this is some issue with my local proxy? Perhaps something specific to VuePress?

Any ideas appreciated!

Could you let us know your sitename so we can take a look at what’s deployed?

@fool thanks for replying.

Figured it out:

I was hitting the wrong port (8080 vs 8888) in my browser. The netlify dev logs are seemingly overwritten by VuePress, which instructed me to visit 8080. You can see my open issue here with more details:

1 Like

tricky! thanks for sharing! i bet someone else needs to know about this…