You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hit the http://localhost:3000/api/something route with a GET request. See that it works as expected. The request is handled
hit the http://localhost:3000/api/something route with a PUT request. See that it works as expected. The request is handled
Run pnpm run build to build a production verison
Run pnpm start to run the production build
hit the http://localhost:3000/api/something route with a GET request. See that it works as expected. The request is handled
hit the http://localhost:3000/api/something route with a PUT request. See that it DOES NOT works as expected. The request is NOT handled. You will receive an HTTP Status 405 Method Not Allowed.
Current vs. Expected behavior
I expected when I hit the PUT endpoint on a production build, even if its next to a GET endpoint, it should work.
Instead I receive a 405 when deployed and when built for production locally. I do NOT get this error when running in dev mode pnpm dev so there is no way for me to validate unless I build a production version locally or wait until its deployed.
Here is a screenshot of this running locally on a production build and returning error 405.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Available memory (MB): 32713
Available CPU cores: 16
Binaries:
Node: 22.1.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.2.3 // Latest available version is detected (14.2.3).
eslint-config-next: 14.2.3
react: 18.3.1
react-dom: 18.3.1
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Vercel (Deployed)
Additional context
This issue has been ongoing since Next13 and I've tried researching a resolution but I guess this isn't something people have encountered often since I couldn't find any reports of this issue. It exists into Next 14 and probably will continue to exist. There is a workaround which is just moving the GET or PUT route to its OWN route folder i.e., /api/something/add for PUT.
The text was updated successfully, but these errors were encountered:
Can confirm that opting out of caching solves this issue but its not a valid solution in the off chance you want to cache the "cacheable" requests like GET but not cache requests like PUT
Also if nothing else, the error should not be "Method not allowed", this could be a development runtime error with some helpful steps for devs to know this sort of this just isnt supported and they can either move the route, or opt out of caching to resolve it.
Link to the code that reproduces this issue
https://github.com/chukwumaokere/app-route-get-put-bug-minimal-repro
To Reproduce
pnpm dev
http://localhost:3000/api/something
route with aGET
request. See that it works as expected. The request is handledhttp://localhost:3000/api/something
route with aPUT
request. See that it works as expected. The request is handledpnpm run build
to build a production verisonpnpm start
to run the production buildhttp://localhost:3000/api/something
route with aGET
request. See that it works as expected. The request is handledhttp://localhost:3000/api/something
route with aPUT
request. See that it DOES NOT works as expected. The request is NOT handled. You will receive an HTTP Status 405 Method Not Allowed.Current vs. Expected behavior
I expected when I hit the
PUT
endpoint on a production build, even if its next to aGET
endpoint, it should work.Instead I receive a 405 when deployed and when built for production locally. I do NOT get this error when running in dev mode
pnpm dev
so there is no way for me to validate unless I build a production version locally or wait until its deployed.Here is a screenshot of this running locally on a production build and returning error 405.
![image](https://private-user-images.githubusercontent.com/16673873/337705052-4855801a-bdaf-421a-9ea4-337223206189.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0NTY2MjAsIm5iZiI6MTcyMjQ1NjMyMCwicGF0aCI6Ii8xNjY3Mzg3My8zMzc3MDUwNTItNDg1NTgwMWEtYmRhZi00MjFhLTllYTQtMzM3MjIzMjA2MTg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MzElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzMxVDIwMDUyMFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVlMjQ2MzhkNTJlN2M2YzJmNjhjNGM2ODAxNmJjYTI3MTBkY2UwMzVjNzFlYmIyOGRiMTQ1YjFhNDFhZWE3ZGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.R-2T9mlAotK9_Jy-yv-8ZcUnAdj-llDNllrcaSLWVRk)
Provide environment information
Which area(s) are affected? (Select all that apply)
Runtime
Which stage(s) are affected? (Select all that apply)
next build (local), next start (local), Vercel (Deployed)
Additional context
This issue has been ongoing since Next13 and I've tried researching a resolution but I guess this isn't something people have encountered often since I couldn't find any reports of this issue. It exists into Next 14 and probably will continue to exist. There is a workaround which is just moving the GET or PUT route to its OWN route folder i.e.,
/api/something/add
for PUT.The text was updated successfully, but these errors were encountered: