title: Cannot POST /login Node.js
body: <p>I'm working with PassportJS and javascript to login and signup a new user. Then, after the signup part (which works perfectly), when I try to login I receive the page "Cannot POST /login". Can you help me understanding which is the error? Here is my code:</p>
  
  <pre><code>'use strict';
  var express = require('express');
  var router = express.Router();
  var middleware =  require('../middleware');
  var rootUrl = require("../../config").url;
  //supported methods
  router.all('/', middleware.supportedMethods('GET, OPTIONS'));
  // As with any middleware it is quintessential to call next()
  // if the user is authenticated
  var isAuthenticated = function (req, res, next) {
  if (req.isAuthenticated())
      return next();
  res.redirect('/');
  };
  
  router.get('/library', isAuthenticated, function(req, res){
       res.render('library', { user: req.user });
  });
  
  module.exports = function(passport){
  
  /* GET login page. */
  router.get('/', function(req, res) {
      // Display the Login page with any flash message, if any
      res.render('library');
  });
  
  /* Handle Login POST */
  router.post('/users', passport.authenticate('users', {
      successRedirect: '/library',
      failureRedirect: '/'
  }));
  
  /* GET Registration Page */
  router.get('/signup', function(req, res){
      res.render('login');
  });
  
  /* Handle Registration POST */
  router.post('/signup', passport.authenticate('signup', {
      successRedirect: '/login',
      failureRedirect: '/signup'
  }));
  
  return router;
  };
  </code></pre>
  
  <p>And in the part of the dust (where I ask for the POST), I have the following code:</p>
  
  <pre><code>&lt;!doctype html&gt; 
  &lt;html&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta name="viewport" content="initial-scale=1.0"&gt;
    &lt;title&gt;Login&lt;/title&gt;
    &lt;link rel="stylesheet" href="css/standardize.css"&gt;
    &lt;link rel="stylesheet" href="css/base.css"&gt;
    &lt;link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"&gt;
  
  &lt;/head&gt;
  &lt;body class="body login"&gt;
    &lt;div class="vertical-align-wrapper"&gt;
      &lt;div class="vertical-align-box"&gt;
        &lt;h1 class="slogan"&gt;We make your &lt;i class="fa fa-heart beats pulse" style="color:#3b7cff;"&gt;&lt;/i&gt; beats.&lt;/h1&gt;
        &lt;div class="form-login-wrapper"&gt;
          &lt;form action="/login" method="POST" class="form-login"&gt;
        &lt;input class="form-control form-stacked" name="userName" placeholder="Username" type="text"&gt;
        &lt;input class="form-control form-stacked last" name="password" placeholder="Password" type="password"&gt;
        &lt;input class="btn btn-beats btn-block btn-stacked" value="Tune in" type="submit" id="submit"&gt;
      &lt;/form&gt;
      &lt;p&gt;Don't have an account? &lt;a href="signup" class="beats"&gt;&lt;strong&gt;sign up&lt;/strong&gt;&lt;/a&gt; now!   &lt;/p&gt;
      &lt;/div&gt; 
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;h1 class="fat blue-glow bottom-right"&gt;Atelier&lt;span class="pulse" style="display:inline-block;"&gt;Beats.&lt;/span&gt;&lt;/h1&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And here is my login code:</p>
  
  <pre><code>/** @module users/router */
  'use strict';
  
  var express = require('express');
  var router = express.Router();
  var middleware =  require('../middleware');
  var rootUrl = require("../../config").url;
  
  
  //supported methods
  router.all('/', middleware.supportedMethods('GET, OPTIONS'));
  
  //list users
  router.get('/', function(req, res, next) {
  
  res.render('login');
  });
  /** router for /users */
  module.exports = router;
  </code></pre>