405 Method Not Allowed
- Next.js
- Any API
What it means
The address exists, but it does not accept this kind of request. For example the page sends a POST and the route only handles GET.
Why it happens
- A Next.js route handler exports only GET, but the form or fetch sends POST.
- A form without method=post sends GET.
- A static host receiving a POST it cannot run.
How to fix it
- Match the method: export the method the page sends (export async function POST).
- Set the method explicitly in fetch or the form.
- Make sure the route is deployed as a server function, not a static file.
Let your AI find the cause
Paste this into Claude Code, Cursor, Lovable or whichever AI built your app. It looks first and changes nothing until you have read the answer.
A request in my app fails with 405 Method Not Allowed. Without changing anything yet, show me the request's method and address, the route file that handles that address, and which methods it supports.