Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Prevent HTTP Parameter Polution in NodeJS

/*   https://www.npmjs.com/package/hpp   */

npm install hpp --save

// ...
var hpp = require('hpp');
 
// ...
app.use(bodyParser.urlencoded()); // Make sure the body is parsed beforehand.
 
app.use(hpp()); // <- THIS IS THE NEW LINE
 
// Add your own middlewares afterwards, e.g.:
app.get('/search', function (req, res, next) { /* ... */ });
// They are safe from HTTP Parameter Pollution now.
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #Prevent #HTTP #Parameter #Polution #NodeJS
ADD COMMENT
Topic
Name
4+4 =