serverless-http icon indicating copy to clipboard operation
serverless-http copied to clipboard

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

Open ruslantalpa opened this issue 1 year ago • 2 comments

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

ruslantalpa avatar Apr 25 '23 08:04 ruslantalpa

Thanks I will look in to this

dougmoscrop avatar Apr 25 '23 12:04 dougmoscrop

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

sladg avatar Jun 01 '23 19:06 sladg