-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Closed
Description
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'.
I'm using router.use and that doesn't seem to play nice.
For example, this doesn't work;
import express from 'express';
const router = express.Router();
app.use(express.json({ limit: '2MB' }));
router.use('/products', products);
router.use('/uploads', express.json({ limit: '10MB' }), uploads);
app.use('/v4', router);I thought about making a middleware that just checks if the req.path is '/uploads', but it seems calling express.json() from a middleware causes some issue.
Not sure whether this is a bug or if I'm just being dumb, but some help would be appreciated. :)