Maximum request length in node.js

For security, I would like to set the maximum request length in my node.js application. (There are many security vulnerabilities that web servers use that allow unlimited request lengths).

Is it possible? Is there another one?

+6
source share
1 answer

I assume that you mean data that the client can send to you through POST. If you use Express, you can use limit middleware to achieve this: http://senchalabs.github.com/connect/middleware-limit.html

A short version of what has been done there:

req.on('data', function(chunk){ received += chunk.length; if (received > bytes) req.destroy(); }); 
+1
source

Source: https://habr.com/ru/post/904857/


All Articles