cli
cli copied to clipboard
Functions 404 with Netlify Dev and a linked project
- Do you want to request a feature or report a bug? BUG
- What is the current behavior?
All functions return 404 not found running netlify dev when netlify link is initialized. Meaning the directory .netlify exists in the project root allong with state.json in that directory filled with its proper site id.
# PROJECT_ROOT/.netlify/state.json
{
"siteId": SOME_SITE STRING
}
- If the current behavior is a bug, please provide the steps to reproduce.
- add new project in netlify and also create a new directory locally with a functions directory and at least one function. (do NOT link or init local dir yet)
- add netlify.toml configuration to project root with splat proxy redirect to functions (see netlify.toml setup below)
- first run
netlify devand test route using curl hitting proxydefault: localhost:8888/api/yourFuncthis should return a response correctly - now run
netlify linkto link up the project created in netlify platform - restart
netlify devand re-curl proxy endpointdefault: localhost:8888/api/yourFunc. Now you get 404 response
- What is the expected behavior?
- netlify dev should use all local configuration regardless of linking the project or not.
- Also env injection should be available via a flag not by default. The functions should return as usual without using any network. NOTE: this fails even with the
--offlineflag appended - When linked the base directory should be implied the current working directory, no? Sensible default
- Local Environment Information Using defaults aside from a redirect proxy splat rule in netlify.toml
[build]
command = "#"
publish = "public/"
functions = "functions"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
status = 200
force = true
Running netlify dev without linking
◈ Netlify Dev ◈
◈ No app server detected and no "command" specified
◈ Running static server from "netlify-serverless/public" <-- CORRECT DEFAULTS
◈ Server listening to 3999
◈ Functions server is listening on 34121
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
◈ Rewrote URL to /.netlify/functions/someFunc
Request from ::ffff:127.0.0.1: GET /.netlify/functions/someFunc
Response with status 200 in 10 ms.
Running netlify dev with project linked (ie .netlify/state.json in project root)
◈ Netlify Dev ◈
◈ No app server detected and no "command" specified
◈ Running static server from "netlify-serverless/public/public" <-- NOTICE because 'base' is not set in netlify.toml
◈ Server listening to 3999
◈ Functions server is listening on 40657
┌─────────────────────────────────────────────────┐
│ │
│ ◈ Server now ready on http://localhost:8888 │
│ │
└─────────────────────────────────────────────────┘
◈ Rewrote URL to /.netlify/functions/someFunc
Request from ::ffff:127.0.0.1: GET /.netlify/functions/someFunc
Response with status 404 in 4 ms.
netlify-cli/2.54.0 linux-x64 node-v12.16.2
I noticed this issue today when walking through https://docs.netlify.com/get-started/. The redirect worked until I ran ntl link.
netlify-cli/9.13.0 linux-x64 node-v16.14.0
Hey @jbool24 & @ddrake, I was trying to debug this but couldn't reproduce the issue. I'm using netlify-cli/11.8.3. Can you update the cli package and let me know if you're still experiencing the issue.
Closing as stale. Please re-open if needed