Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 404 Page Redirection for Invalid Routes #123

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading