mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +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
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function(req, res, next) {
|
||||||
var err = new Error('Not Found');
|
//var err = new Error('Not Found');
|
||||||
err.status = 404;
|
//err.status = 404;
|
||||||
res.render('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);
|
//next(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user