title: express routes not working - returning 404 error
body: <p>I'm trying to set up a simple express project, and backend will be purely for api and frontend will be vue. I tried adding an api router, and not only does it not work, but even the root page doesn't work. I've not coded in express for a very long time, and wondering if some one could guide me on what's the problem? The error message is <code>404 NotFoundError: Not Found</code>.</p>
  <p>I'm navigating to localhost:3000, and I can see the call on the terminal, so port should be correct too?</p>
  <pre><code>/src/api/urls.js
  var express = require('express');
  var router = express.Router();
  
  
  router.get('/', function(req, res) {
    res.send('Just a test');
  });
  
  module.exports = router;
  </code></pre>
  <p>I didn't change the folder structure/naming for the original routes/index.js.</p>
  <pre><code>/src/routes/index.js
  var express = require('express');
  var router = express.Router();
  
  
  router.get('/', function(req, res) {
    res.send('Just a test');
  });
  
  module.exports = router;
  </code></pre>
  <p>And for the main file</p>
  <pre><code>/src/app.js
  var createError = require('http-errors');
  var express = require('express');
  var path = require('path');
  var cookieParser = require('cookie-parser');
  var logger = require('morgan');
  
  var indexRouter = require('./routes/index');
  var apiRouter = require('./api/urls');
  
  var app = express();
  
  app.use(require('connect-history-api-fallback')());
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  
  app.use(logger('dev'));
  app.use(express.json());
  app.use(express.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', indexRouter);
  app.use('/api', apiRouter);
  
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    next(createError(404));
  });
  
  // error handler
  app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
  
    // render the error page
    res.status(err.status || 500);
    res.render('error');
  });
  
  module.exports = app;
  </code></pre>