1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-11 02:12:53 +00:00

fixed 404 page

This commit is contained in:
2016-04-07 10:22:04 -05:00
parent 06b4fad391
commit 2a173cbc31

22
app.js
View File

@@ -48,9 +48,25 @@ app.use('/upload', upload);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
res.render('404');
//var err = new Error('Not Found');
//err.status = 404;
res.status(404);
// respond with html page
if (req.accepts('html')) {
res.render('404', { url: req.url });
return;
}
// respond with json
if (req.accepts('json')) {
res.send({ error: 'Not found' });
return;
}
// default to plain-text. send()
res.type('txt').send('Not found');
//next(err);
});