title: Getting error while connecting node and mongo as cannot GET /
body: <p>Hello everyone I'm trying to connect mongo and node. But i'm getting cannot GET Please help me with this
  My code is as follows. It would be great if someone helps me in resolving this issue
  app.js</p>
  
  <pre><code>var express = require("express");
  var bodyParser = require("body-parser");
  const mongoose = require('mongoose');
  mongoose.connect('mongodb://localhost:27017/NammaDB');
  var db = mongoose.connection;
  db.on('error', console.log.bind(console, "connection error"));
  
  db.once('open', function(callback) {
      console.log("connection succeeded");
  })
  var app = express()
  app.use(bodyParser.json());
  app.use(express.static('public'));
  app.use(bodyParser.urlencoded({
      extended: true
  }));
  app.post('login', function(req, res) {
      var name = req.body.username;
      var pass = req.body.password;
      var data = {
          "eid": hello,
          "pwd": hello,
      } 
      db.collection('users').insertOne(data, function(err, collection) {
          if (err) throw err;
          console.log("Record inserted Successfully");
  
      });
  
      return res.redirect('/login.html');
  })
  
  
  app.get('/', function(req, res) {
      res.set({
          'Access-control-Allow-Origin': '*'
      });
      return res.redirect('login.html');
  }).listen(3000)
  console.log("server listening at port 3000");
  </code></pre>
  
  <p>My index.js code is as follows
  index.js</p>
  
  <pre><code>const express = require('express');
  
  const router = express.Router();
  
  router.get('/', (req, res) =&gt; {
    res.send('It works!');
  });
  
  module.exports = router;
  </code></pre>