mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 02:12:53 +00:00
fixed 404 page
This commit is contained in:
22
app.js
22
app.js
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user