Node.js based forum software built for the modern web
Updated 404 for image handling
Julian Lama50091414360
diff --git a/src/routes/index.js b/src/routes/index.jsindex 395557ef4b..999528aadf 100644--- a/src/routes/index.js+++ b/src/routes/index.js@@ -174,10 +174,8 @@ function handle404(app, middleware) {res.type('text/javascript').status(200).send('');} else if (isLanguage.test(req.url)) {res.status(200).json({});- } else if (req.path.startsWith(relativePath + '/uploads')) {- res.status(404).send('');- } else if (req.path === '/favicon.ico') {- res.status(404).send('');+ } else if (req.path.startsWith(relativePath + '/uploads') || req.get('accept').indexOf('text/html') === -1 || req.path === '/favicon.ico') {+ res.sendStatus(404);} else if (req.accepts('html')) {if (process.env.NODE_ENV === 'development') {winston.warn('Route requested but not found: ' + req.url);diff --git a/src/routes/plugins.js b/src/routes/plugins.jsindex 0123433db9..18c928e3af 100644--- a/src/routes/plugins.js+++ b/src/routes/plugins.js@@ -26,6 +26,15 @@ module.exports = function(app, middleware, controllers) {return next();}- res.sendFile(matches[0]);+ res.sendFile(matches[0], {}, function(err) {+ if (err) {+ if (err.code === 'ENOENT') {+ // File doesn't exist, this isn't an error, to send to 404 handler+ return next();+ } else {+ return next(err);+ }+ }+ });});};\ No newline at end of file