Closed
Description
Describe the bug
When running netlify dev
with the -t
flag,POST
requests to local Netlify functions fail with a "400 bad request" error. GET
requests work fine.
Running netlify dev
without the -t
flag makes POST
requests work again.
To Reproduce
- Clone this minimal reproduction repo: https://github.com/nonAlgebraic/netlify-cli-function-post-bug-repro
- Navigate to the cloned repository
- Run
yarn install
- Run
yarn run netlify dev -t
- Observe that the
GET
request to/.netlify/functions/hello
is successful, while thePOST
request to the same URL fails. - Try running
yarn run netlify dev
(without the-t
flag) and observe both theGET
and thePOST
requests succeed.
Configuration
netlify.toml
:
[dev]
command = "yarn start"
framework = "#custom"
publish = "public"
targetPort = 8080
port = 9090
[build]
functions = "functions"
Output of envinfo
:
System:
OS: macOS 11.1
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 239.36 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
Yarn: 1.22.10 - ~/projects/netlify-cli-function-post-bug-repro/node_modules/.bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
npmPackages:
netlify-cli: ^3.1.0 => 3.1.0
Expected behavior
Both POST
and GET
requests to a local Netlify function should work when running netlify dev -t
.
Additional context
Note: if you POST
to the functions server directly (i.e. instead of POST
ing to the main proxied netlify dev
server), it works fine.