Suddenly errors "Invalid method" in a normal fetch POST which always worked since years

fetch always been:
const response = await fetch(url, {
method: “POST”,
headers: {
‘Content-Type’: ‘application/json’
},
body: JSON.stringify(dataz),
})
const data = await response.json()

and api route always started with:

export default async function (req, res) {

if (req.method === “POST”) {
… etc.

and worked fine, what are now these errors “Invalid method” at the api route level? error 405

Hi @m4tt86!

Is your app on Next.js? Sounds similar to this issue, could you follow this same process?

Yes it’s on Next.js
added headers for api routes inside config as the guy in the link you provided but didn’t resolve
also I don’t think that guy found a solution to this issue either.
Not to mention this always worked fine for years and Next.js version as well as other npm remained the same.
To add to it, Vercel log of errors doesn’t display the error 405, so I can’t debug it.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.