cli icon indicating copy to clipboard operation
cli copied to clipboard

Redirect converts POST request to a GET request without body

Open varna opened this issue 3 years ago • 3 comments

Describe the bug

Redirect converts POST request to a GET request without body

To Reproduce

Steps to reproduce the behavior:

  1. Create a POST function i.e. /.netlify/functions/create-ticket
  2. Redirect /create-ticket to /.netlify/functions/create-ticket via _redirects or netlify.toml
  3. POST /create-ticket redirects to GET /.netlify/functions/create-ticket without body

Same happens in netlify dev (netlify-cli/3.39.0 darwin-x64 node-v12.7.0) and production deployments.

Configuration

  • If possible, please copy/paste below your netlify.toml:
[build]
  functions = "functions"
[[redirects]]
  from = "/create-ticket"
  to = "/.netlify/functions/create-ticket"
  • Please enter the following command in a terminal and copy/paste its output:
  System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 114.97 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 12.7.0 - ~/.nvm/versions/node/v12.7.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.0.10 - /usr/local/bin/npm
  npmGlobalPackages:
    netlify-cli: 3.39.0

Expected behavior

POST /create-ticket redirects to POST /.netlify/functions/create-ticket with body

CLI Output

While in netlify dev and requesting POST /create-ticket I receive this message in bash:

Request from ::1: GET /.netlify/functions/create-ticket

varna avatar Jun 29 '21 09:06 varna

I'm encountering this bug too, has it been patched?

rgrannell1 avatar Apr 10 '22 14:04 rgrannell1

I'm encountering this bug too, has it been patched?

dunno, haven't touched that project since 2021 Jun

varna avatar Apr 11 '22 07:04 varna

Try with temporary redirect status

[[redirects]]
  from = "/create-ticket"
  to = "/.netlify/functions/create-ticket"
  status=307 // <-- temporary redirect
  force = true

Razz21 avatar Jun 23 '22 15:06 Razz21