Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Security concern using express.bodyParser()</strong></p> <p>While all the other answers currently recommend using the <code>express.bodyParser()</code> middleware, this is actually a wrapper around the <code>express.json()</code>, <code>express.urlencoded()</code>, and <code>express.multipart()</code> middlewares (<a href="http://expressjs.com/api.html#bodyParser">http://expressjs.com/api.html#bodyParser</a>). The parsing of form request bodies is done by the <code>express.urlencoded()</code> middleware and is all that you need to expose your form data on <code>req.body</code> object.</p> <p>Due to a <a href="https://groups.google.com/forum/#!msg/express-js/iP2VyhkypHo/5AXQiYN3RPcJ">security concern</a> with how <code>express.multipart()</code>/<code>connect.multipart()</code> creates temporary files for all uploaded files (and are not garbage collected), it is now <em><a href="https://github.com/senchalabs/connect/wiki/Connect-3.0">recommended</a></em> not to use the <code>express.bodyParser()</code> wrapper but instead use only the middlewares you need.</p> <p>Note: <code>connect.bodyParser()</code> will soon be updated to only include <code>urlencoded</code> and <code>json</code> when Connect 3.0 is released (which Express extends).</p> <hr> <p>So in short, instead of ...</p> <pre><code>app.use(express.bodyParser()); </code></pre> <p>...you should use</p> <pre><code>app.use(express.urlencoded()); app.use(express.json()); // if needed </code></pre> <p>and if/when you need to handle multipart forms (file uploads), use a third party library or middleware such as multiparty, busboy, dicer, etc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload