fix/middleware preventing 404 redirect

This commit is contained in:
SowinskiBraeden committed 2025-05-07 13:01:24 -07:00
1 parent f417ac00fb
commit cadbc2187d
3 files changed
+44 -4

No files matched your search

+9 -3
View File
@@ -84,23 +84,29 @@ app.post('/api/location', async (req,res) => {
res.json(data);
});
// 404 handler - keep the actual notFound route please
app.get('/notFound', (req, res) => {
res.render('notFound');
return res.status(status.NotFound);
});
// Initialize database and start app
initDatabase().then(() => {
console.log("Successfully connected to MongoDB");
// Import authentication handler
app.use(require("./src/auth/authentication")(users));
// Import middleware & apply to user routes
const middleware = require("./src/auth/middleware")(users);
app.use(require('./src/router/user')(middleware, users, plans, assets));
// 404 handler
app.get('/*splat', (req, res) => {
res.send('404 Not Found');
res.render('notFound');
return res.status(status.NotFound);
});
// Start app
app.listen(port, () => {
console.log(`Server listening on port ${port}`);