Skip to content

Commit

Permalink
Merge pull request #123 from Aman-G-upta/main
Browse files Browse the repository at this point in the history
Fix 404 Page Redirection for Invalid Routes
  • Loading branch information
jinx-vi-0 authored Nov 6, 2024
2 parents 8491d78 + ce2db5c commit 726232b
Show file tree
Hide file tree
Showing 3 changed files with 462 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ app.use(
app.use(passport.initialize());
app.use(passport.session()); // Persist user sessions

// app.use(flash());

// Global variables for flash messages
app.use((req, res, next) => {
Expand All @@ -85,9 +86,14 @@ app.set('view engine', 'ejs');
app.locals.isActiveRoute = isActiveRoute;

// Routes

app.use('/', require('./server/routes/main'));
app.use('/', require('./server/routes/admin'));

app.use((req, res, next) => {
res.status(404).render('404',{ layout: false }); // Renders the 404.ejs file
});

// Start the server
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
Expand Down
Loading

0 comments on commit 726232b

Please sign in to comment.