Friday 14 April 2017

Express: limit request size

To limit the request size to 123 bytes, I use the following which works fine:

app.use(bodyParser.urlencoded({
    extended: true,
    limit: 123
}));

To parse all requests except for "/specialRequest", I use the following which works fine as well:

app.use(/^(?!\/specialRequest)/,bodyParser.urlencoded({
    extended: true
}));

But I fail to limit the request size of all requests to 123 and parse all requests except for "/specialRequest". Here is my current code:

app.use(/^(?!\/specialRequest)/,bodyParser.urlencoded({
    extended: true,
    limit: 123
}));

However, this only limits the requests size for requests different than "/specialRequest". How can I limit the request size of all requests to 123 and parse all requests except for "/specialRequest"?



via BJPrim

No comments:

Post a Comment