-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
4.xDocs for 4.x versionDocs for 4.x version5.xDocs for 5.x versionDocs for 5.x versiondocsIssues/pr concerning contentIssues/pr concerning content
Description
In the following issue, it is requested to customize the body size limit for express.json()
dynamically based on the API route:
@marbuser (Apr 11, 2019):
I've got some endpoints and 90% of them I want to have a limit of around '2MB'. However, there is 1 specific route, my upload route, where I want to have an upload limit of '10MB'.
There are some solutions provided in the thread, but maybe a simpler option would be this one inspired by this Stack Overflow answer:
// Parse application/json
// - limit on /upload: 5MB
// - limit on other routes: default of 100KB
app.use('/upload', express.json({ limit: '5mb' }));
app.use(/^(?!\/upload$)/, express.json());
This may be a nice example to document on the express.json()
docs section
itsalb3rt and elijaholmos
Metadata
Metadata
Assignees
Labels
4.xDocs for 4.x versionDocs for 4.x version5.xDocs for 5.x versionDocs for 5.x versiondocsIssues/pr concerning contentIssues/pr concerning content