While working on developing a day planner, I encountered an issue with the routes. I am consistently receiving a 404 error for any route other than the main Home page route (index or "/").
Below is the content of the app.js file:
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var calendarRouter = require('./routes/calendar');
// More code goes here...
module.exports = app;
The next part focuses on the calendar.js route:
var express = require('express');
var router = express.Router();
// More code goes here...
module.exports = router;
Also, there is information about the index.js route where redirection occurs:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.redirect('/calendar');
});
module.exports = router;
Lastly, we have the Controller for the calendar.js route:
var Schedule = require('../models/schedule');
exports.index = function(req, res) {
res.send('NOT IMPLEMENTED: Site Home Page');
};
// More controller functions go here...
module.exports = router;