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. :)
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.useand that doesn't seem to play nice.For example, this doesn't work;
I thought about making a middleware that just checks if the
req.pathis '/uploads', but it seems callingexpress.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. :)