dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.73k stars 167 forks source link

body-parser middleware not triggering in Express 5/body-parser 2.x #274

Open ruslantalpa opened 1 year ago

ruslantalpa commented 1 year ago

body-parser 2.x used in express 5 changed how it checks if the post body was read to this: https://github.com/jshttp/on-finished/blob/master/index.js#L76

At the same time, serverless-http is setting the body to a buffer. Also, on this line it's saying the body is not readable https://github.com/dougmoscrop/serverless-http/blob/master/lib/request.js#L9

because of this, body-parser middleware does not get executed.

If in request.js readable is changed to true, everything is working. Maybe that should be changed to:

readable:  Buffer.isBuffer(body)

Thank you

dougmoscrop commented 1 year ago

Thanks I will look in to this

sladg commented 1 year ago

Facing same issue. slsHttp is returning Buffer as a body instead of JSON.