Next.js routes respond with 200 to unsupported HTTP methods
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/github/vercel/next.js/tree/canary/examples/reproduction-template
To Reproduce
- Open codesandbox
- Copy Preview URL
- Using your tool of choice, make any non GET request (POST, PATCH, DELETE, etc)
Current vs. Expected behavior
Current:
- 200 response, with HTML document matching the GET route
- Client side error once JS loads
Application error: a client-side exception has occurred while loading (see the browser console for more information).
Expected:
405 - Method not allowed
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
Node: 20.9.0
npm: 10.1.0
Yarn: 3.5.0
pnpm: 10.5.2
Relevant Packages:
next: 13.4.19
eslint-config-next: 15.3.0
react: 18.3.1
react-dom: 18.3.1
typescript: 5.8.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed), next start (local), next dev (local), next build (local), Other (Deployed)
Additional context
I've tested this both self hosted and on Vercel, with 200's on each. The next.js website returns a 405 as expected.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction template and send POST, PATCH, and DELETE requests to the copied Preview URL. Compare behavior in next dev, next start, next build, and deployed environments; done means unsupported methods consistently return 405 instead of the GET HTML response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100