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:
@@ -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)=>{
|
||||
|
||||
Reference in New Issue
Block a user