Can't use Netlify function in Netlify Dev mode

I’m new to Netlify and I’ve created a Netlify function (inviteUser) which I’m able call from my application. This works great in production mode, but I would like to be able to use it in development mode too.

The function is located in /netlify/functions. I’ve installed the Netlify CLI and configured a netlify.toml file in my root directory to specify the functions directory:

[build]
functions = "netlify/functions"

When I attempt to use the function when running in dev mode with “netlify dev” I receive an error:
“POST http://localhost:3000/.netlify/functions/inviteUser 500 (Internal Server Error)”

I cam attempting to use the function like so:

fetch('/.netlify/functions/inviteUser', { ... })

I’m not sure how to get this working in dev mode. What am I doing wrong?

Hi @ddilly-sixmo

By default netlify dev runs on port 8888, not port 3000 which is often only where the framework (e.g. Vue, React, Astro) runs.

Are you able to access the function (and your app) using port 8888 instead? If not, can you share the repository you are working with?