Why am I getting 'Method Not Allowed Error' in vercel

25 views Asked by At

I developed this website- https://snotes00.vercel.app

but I am facing an issue while sending request to vercel backend- POST https://snotes00.vercel.app/server/login net::ERR_ABORTED 405 (Method Not Allowed) I was sending the request from- https://snotes00.vercel.app/login

While running in local server, it works alright., it causes this issue only in vercel.

I am running the front end on https://snotes00.vercel.app and backend on https://snotes00.vercel.app/server

Github repo- https://github.com/sayanbose-0000/snotes

Please help me fix it

[NOTE: I don't think there is an error in my code, cause it works fine in local server... Is there a problem in how I set up the env variables?]

1

There are 1 answers

4
adampweb On

If you used the Free plan of Vercel this caused the issue. Because it provides only Edge runtime but JWT cannot run on Edge runtime. You need to use an alternative for authorization (e.g.: jose) which is supported by Edge runtime.

In this discussion of official Vercel GitHub repo you can find an example implementation of jose: https://github.com/vercel/next.js/issues/43115#issuecomment-1321785193