next.js icon indicating copy to clipboard operation
next.js copied to clipboard

POST request succeeds for pages with next dev

Open nkzawa opened this issue 3 years ago • 3 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022; root:xnu-8020.121.3~4/RELEASE_X86_64
Binaries:
  Node: 16.14.0
  npm: 8.12.0
  Yarn: 1.22.17
  pnpm: 7.5.2
Relevant packages:
  next: 12.2.3-canary.15
  eslint-config-next: 12.2.2
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When you send a POST request to a page running with next dev, it succeeds with 200 status even though it fails with 405 status when running with next start

Expected Behavior

Non-GET/HEAD requests fail with 405 status code in the same way with next start

Link to reproduction

https://github.com/vercel/next.js/tree/canary/examples

To Reproduce

$ next dev

# on another terminal
$ curl http://localhost:3000 -X POST -v

The problem should happen on any apps.

nkzawa avatar Jul 21 '22 10:07 nkzawa

Does someone want to push https://github.com/vercel/next.js/pull/38870 over the finish line?

jankaifer avatar Jan 18 '23 16:01 jankaifer

#38870 is now closed as stable, is this something we still want to look into? Or is this ticket still relevant without the need for that one?

Tigatok avatar Dec 12 '23 15:12 Tigatok

Hi! 👋 I’d like to work on making next dev return a 405 status for non-GET/HEAD requests, matching next start behavior. My plan is to check the request method in the dev server route handling and return the appropriate 405 response for unsupported methods. Could you please assign this issue to me? Thanks!

Prasad-JB avatar Aug 10 '25 09:08 Prasad-JB

Hi I would also like to work on this issue. I am a first time contributor and thing this would be great to help me get experienced with contributing to Next.js.

OwenS3881 avatar Sep 01 '25 19:09 OwenS3881