Skip to content

Instantly share code, notes, and snippets.

@BCsabaEngine
Created October 8, 2020 10:26
Show Gist options
  • Save BCsabaEngine/bd3bcc780681297b9079126135ec2989 to your computer and use it in GitHub Desktop.
Save BCsabaEngine/bd3bcc780681297b9079126135ec2989 to your computer and use it in GitHub Desktop.
Re404 - move 404 error handler at the end of routing
Page404 = function (req, res, next) { res.status(404).render('page404', { title: "Oops 404!" }); }
app.re404 = () => { app.remove(Page404); app.use(Page404); }
app.re404();
// and call app.re404() function after adding new routes (eg. when loading submodules)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment