0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 14:12:40 +00:00

Add catch-all for invalid paths

res.route is the currently-matched route. If nothing has been matched by this point (route = undefined), we have an invalid route.
This commit is contained in:
Trevor Buckner
2024-08-20 17:11:50 -04:00
parent defbc716c0
commit 0f969ce383

View File

@@ -420,6 +420,14 @@ if(isLocalEnvironment){
});
}
// Catch-all route for invalid routes
app.use((req, res, next) => {
if (!req.route)
return res.redirect('/');
return next();
});
//Render the page
const templateFn = require('./../client/template.js');
const renderPage = async (req, res)=>{