Skip to content

Instantly share code, notes, and snippets.

@Fishrock123
Created January 8, 2014 23:37
Show Gist options
  • Save Fishrock123/8326816 to your computer and use it in GitHub Desktop.
Save Fishrock123/8326816 to your computer and use it in GitHub Desktop.
// Site 404
app.use(function(req, res, next) {
res.status(404)
if (req.accepts('html')) {
res.type('html')
res.render('404', {
url: req.get('host') + req.url,
user: req.user,
version: version
})
return
}
if (req.accepts('json')) {
res.type('json')
res.json({ error: '404: Not found' })
return
}
res.type('txt')
res.send('404: Not found')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment