Skip to content

Running netlify dev with the -t flag causes POST requests to /.netlify/functions to fail #1724

Closed
@nonAlgebraic

Description

@nonAlgebraic

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

  1. Clone this minimal reproduction repo: https://github.com/nonAlgebraic/netlify-cli-function-post-bug-repro
  2. Navigate to the cloned repository
  3. Run yarn install
  4. Run yarn run netlify dev -t
  5. Observe that the GET request to /.netlify/functions/hello is successful, while the POST request to the same URL fails.
  6. Try running yarn run netlify dev (without the -t flag) and observe both the GET and the POST 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 POSTing to the main proxied netlify dev server), it works fine.

Metadata

Metadata

Assignees

Labels

type: bugcode to address defects in shipped code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions