I have a very simple express server hosted on vercel using serverless functions. You can follow this guide to get to where I am: https://vercel.com/guides/using-express-with-vercel#standalone-express
I then added 2 endpoints of my own.
I added this route which works perfectly, does not read from req.body though:
app.get('/create-room', function (req, res) {
res.end(JSON.stringify(
{ "room_id": Math.random().toString(36).slice(-6) }
));
});
The route having issues is this:
app.post('/auth', function (req, res) {
const { body } = req;
return res.end(Hello ${body.name}, you just parsed the request body!);
});
My vercel.json is this, I changed the source value on purpose, no bigge:
{
"rewrites": [{ "source": "/(.*)", "destination": "/api" }]
}
My deployed url to the broken endpoint is this: https://meeting-backend-vercel.vercel.app/auth, you can curl to it with curl -X POST "https://meeting-backend-vercel.vercel.app/auth" -H "Content-Type: application/json" -d '{ "name": "Reader" }'. You can curl to the /create-room endpoint which works fine with this: curl -X GET https://meeting-backend-vercel.vercel.app/create-room. The logs say every time I do the curl to /auth there is a internal server error as it can't read req.body. Why?