Skip to content

Instantly share code, notes, and snippets.

@utsukushiihime
Created September 9, 2020 16:59
Show Gist options
  • Save utsukushiihime/0860ae991781c230658b70ad4b904150 to your computer and use it in GitHub Desktop.
Save utsukushiihime/0860ae991781c230658b70ad4b904150 to your computer and use it in GitHub Desktop.
Expressjs 404 Error Handling
app.use(function (req, res) {
// any get will send 404
if (req.method === "GET") return res.status(404).send("404 Page Not Found");
// any other method will say not allowed
return res.status(405).send("Method not allowed");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment