"405 Method Not Allowed" Error when trying to make a POST request to my "/url" endpoint hosted on Vercel #3911
-
SummaryMy frontend works perfectly fine but I keep getting errors when I'm interacting with my vercel server even though that everything works fine in my localhost !!! Any help please I've been struggling with this for DAAAYS ;/ ExampleNo response Steps to ReproduceMy project Structure is like this :
I've deployed everything on my vercel project and I've specified the routing correctly on vercel.json file
here is the index.js code that receives post requests
and here is the js code that sends the requests:
My frontend works perfectly fine but I keep getting errors when I'm interacting with my vercel server even though that everything works fine in my localhost !!! Any help please I've been struggling with this for DAAAYS ;/ |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
You should put the In your client-side code, you can invoke the endpoint at |
Beta Was this translation helpful? Give feedback.
-
This discussion was automatically locked because the community moved to a new site. Please join us at vercel.community |
Beta Was this translation helpful? Give feedback.
You should put the
index.js
file in theapi
directory instead. That will make it be executed as a Node.js function. Putting it at the root-level like you are doing now will make it be a static file.In your client-side code, you can invoke the endpoint at
POST /api
(index is implied as the default). So there is no need for the rewrite invercel.json
.