body-parser icon indicating copy to clipboard operation
body-parser copied to clipboard

Exclude specific route from body-parsersing

Open cesco69 opened this issue 3 months ago • 0 comments

Hi, in the 1.X versione there is https://github.com/expressjs/body-parser/blob/1.x/lib/read.js#L45-L46

  // flag as parsed
  req._body = true

I have used this flag for exclude a specific route from body parsersing, eg.:

app.use((req, res, next) => {
      if ( /^\/api\/wopi\/files\/([a-zA-Z0-9]+)\/contents$/.test(req.path.toLowerCase()) ) {
        req['_body'] = true;
      }
      next();
});

In the 2.X version this flag disappear... How can I exclude a specific route from body parser?

cesco69 avatar Sep 02 '25 12:09 cesco69