I'm trying to protect the app I'm working on from payload DOS attacks (when someone tries to upload a very big file). My middlewares look like this (I'm using express-fileupload and body-parser:
import fileUpload from "express-fileupload";
import { json, urlencoded } from "body-parser";
// ...
app.use(
    fileUpload({
        limits: { fileSize: 2 * 1024 * 1024 }
    })
);
app.use(json({ limit: "2mb" }));
app.use(urlencoded({ limit: "2mb", extended: true }));
My problem is that despite the fact that I configured my middlewares to limit request size to 2mb when I try to upload a 7gb file the process halts.
How do I prevent this properly?
 
     
    