Skip to content

Instantly share code, notes, and snippets.

@omar2205
Created May 15, 2021 04:21
Show Gist options
  • Save omar2205/8e98d4b9f57666b265a767b64ab8ce17 to your computer and use it in GitHub Desktop.
Save omar2205/8e98d4b9f57666b265a767b64ab8ce17 to your computer and use it in GitHub Desktop.
handle 404 in express js
const express = require('express')
const app = express()
// ~ all routes
// last route
app.use((req, res) => {
res.status(404).send('Custom 404 handler')
})
app.listen(3000, () => console.log('-- SERVER ON PORT 3000')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment