Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nonAlgebraic opened this issue Jan 12, 2021 · 0 comments · Fixed by #1742
Closed
Assignees
Labels
type: bug code to address defects in shipped code

Comments

@nonAlgebraic
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants