azure-function-express
azure-function-express copied to clipboard
Http body already parsed
Thank you for your great product!! I love it. :)
I found a compatibility issue between pure-express and azure-function-express.
In pure-express, the request body is not parsed. It is raw data. In azure-function-express, the request body is already parsed. It is object.
My workaround is as below:
app.post('path',
(req, res, next) => { req.body = req.rawBody; next(); },
otherMiddlewares,
(req, res) => {
// do something
});
I couldn't use bodyParser module on azure-function-express.
What version of azure-function-express are you using?
Oh, sorry. I'm using azure-function-express v2.0.0 on Azure Functions v2.
Sorry, I taked mistake during write this issue.
A module that I tried is clova-cek-sdk-nodejs. https://github.com/line/clova-cek-sdk-nodejs
Because the module expect the type of req.body is string or Buffer or parseable by body-parser, I did a workaround previous wrote. https://github.com/line/clova-cek-sdk-nodejs/blob/master/src/verifierMiddleware.ts#L24
However, body-parser expect a req is behave like stream. https://github.com/stream-utils/raw-body/blob/master/index.js#L190
Because the IncomingMessage that you provide is not behave like stream, then become to no response.
This appears to be a duplicate of #15 where the req object isn't a stream.
I opened a PR which changes the IncomingMessage (wrapped req object) to be a Readable stream with the rawBody pushed. This seems to fix this issue