• Handling 404 pages with express and node.js

    abemassry        
    1 Likes0 Commentsjavascript

    app.get('/404', function(req, res){
        
        if (req.user) {
          var username = req.user.username; 
        }
        
        res.render('404.jade', {
            locals: {
              page: 'Not Found',
              user: username
            }
        });
      });
      
      //last function before end of file
      app.use(function(req,res){
        res.redirect('/404');
      });

Comments (0)