Function not found error while running locally using netlify dev

My HTML-CSS-JS only site with functions use works as expected when deployed
But when I want to test the site locally, I use $ netlify dev command
To run it on my machine, Site (index.html) works fine but it fails to fetch data from function
As that network request gives “Not found” response

$ netlify dev command output is like:
Server listening to 3999
Waiting for localhost:3999.
◈ Lambda server is listening on 51340
Connected!
Waiting for localhost:34567…

My netlify.toml file content:
[build]
base = “./”
functions = “./functions/”
publish = “./src/”
[dev]
publish = “./src/”

I don’t use any SSG, frameworks
How do I get the functions working on my machine for testing purposes?
Note: The site along with functions works perfectly as expected when pushed to netlify

Could you try changing your paths in the netlify.toml to relative paths? Like: src/ and functions/ and leave the base property out. Let me know if doing so helps.

netlify.toml file content:

[build]
	functions = "functions/"
	publish = "src/"
[dev]
	publish = "src/"

These changes didn’t help
Request to my functions still fail

Are you connecting to the Lambda server port? Functions are being served by that:

Netlify deploys over cloud work as expected:

deploy

netlify dev command output:

nd

But on my computer, netlify dev command gives port 3999 for frontend which fails to connect to functions port since they run on random 5xxx port, while my JavaScript code assumes frontend port 3999 (which works well when deployed)

local 3999

My Javascript code:

local js script

On my computer netlify dev commands lambda server port (5xxx) serves the functions as expected:

local functions

My directory structure:

dir str

In short lambda server port and frontend port is different thus function not found is received for frontend function requests

To answer your question exactly: No, I am connecting lambda server port from the frontend. I would never know lambda server port since netlify dev gives random generated lambda server port

Please help me get the functions working together with frontend on my computer with netlify dev command

Are you using netlify-lambda in your build process? Can you try not using it and see how that works? Let me know if that helps.

No, I don’t even have netlify-lambda installed!

I think at the moment netlify dev doesn’t support creating a dev environment where simple JS-HTML apps and netlify functions could could behave like they behave when deployed
Since all the tutorials about netlify dev use either JS frameworks (react) or SSGs

Hi there, sorry this is a bit of a struggle - I just chatted with the folks who work on Dev. Your best bet is to file an issue on the repo, which you can find here:

Sorry we can’t offer more assistance at this time :confused: