Fix /apple-touch-icon not sending uploaded file

This fixes the following error:

$ wget https://nodebb.yourdomain/apple-touch-icon

28/6 09:57:06 [28332] - error: /apple-touch-icon
 Error: ENOENT: no such file or directory, stat '/home/sweet/nodebb/public/assets/uploads/system/touchicon-orig.png'
    at Error (native)
This commit is contained in:
Marc-Aurèle DARCHE
2017-06-28 15:02:17 +02:00
parent 382240f25c
commit 6248e5562f
2 changed files with 17 additions and 3 deletions

View File

@@ -83,7 +83,13 @@ middleware.routeTouchIcon = function (req, res) {
if (meta.config['brand:touchIcon'] && validator.isURL(meta.config['brand:touchIcon'])) {
return res.redirect(meta.config['brand:touchIcon']);
}
return res.sendFile(path.join(__dirname, '../../public', meta.config['brand:touchIcon'] || '/logo.png'), {
var iconPath = '../../public';
if (meta.config['brand:touchIcon']) {
iconPath += meta.config['brand:touchIcon'].replace(/assets\/uploads/, 'uploads');
} else {
iconPath += '/logo.png';
}
return res.sendFile(path.join(__dirname, iconPath), {
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
});
};