title: Error: misconfigured csrf - Express.js
body: <p>I'm getting <code>Error: misconfigured csrf</code> when I'm trying to access my login-page. I'm implementing the csurf to a router, but I'm just getting the response statuscode 500.</p>
  
  <p>Implementation:</p>
  
  <pre><code>let router = require("express").Router();
  
  let PostLoginResource = require("./../resources/PostLoginResource");
  let RateLimit = require("express-rate-limit");
  let csrf = require("csurf");
  
  let csrfProtection = csrf({ cookie: true });
  
  router.route("/login")
      .get(csrfProtection, function(req, res) {
          // Do some stuff
      })
  
      .post(loginLimiter, function(req, res) {
  
          PostLoginResource(req, function(success, err) {
              // Do some stuff
          })
  
      });
  </code></pre>
  
  <p>I'm starting the session-cookie before I'm using this module in app.js:</p>
  
  <pre><code>// Parse the request body as JSON
  app.use(bodyParser.json());
  
  // Parse the URL encoded data
  app.use(bodyParser.urlencoded({extended: true}));
  
  // Set up session-cookie
  app.use(session({
      secret: "secret",
      resave: false,
      saveUninitialized: true,
      cookie: {secure: true,
          httpOnly: true,
          maxAge: 1000 * 60 * 60 * 24
      }
  }));
  </code></pre>
  
  <p>Still, this is not working. Anyone knows what the problem is?</p>