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.
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)
My Javascript code:
On my computer netlify dev commands lambda server port (5xxx) serves the functions as expected:
My directory structure:
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
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: