This commit is contained in:
Raven Scott 2024-09-16 08:21:29 -04:00
parent d4107f8557
commit 1b8477f1cf

10
app.js
View File

@ -147,7 +147,6 @@ app.post('/contact', (req, res) => {
}); });
}); });
// Blog Post Route // Blog Post Route
app.get('/blog/:slug', (req, res) => { app.get('/blog/:slug', (req, res) => {
const slug = req.params.slug; const slug = req.params.slug;
@ -166,15 +165,18 @@ app.get('/blog/:slug', (req, res) => {
blogPosts blogPosts
}); });
} else { } else {
res.status(404).render('404', { title: 'Post not found' }); res.redirect('/'); // Redirect to the home page if the blog post is not found
} }
}); });
// Request a Quote form remains unchanged // Global 404 handler for any other unmatched routes
app.use((req, res) => {
res.redirect('/'); // Redirect to the home page for any 404 error
});
// ================================ // ================================
// Server Listening // Server Listening
// ================================ // ================================
const PORT = process.env.PORT || 8899; const PORT = process.env.PORT || 8899;
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`); console.log(`Server running on http://localhost:${PORT}`);