From fb48ab34550906bf4020baa8cee806d13a6602bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 30 Mar 2026 19:42:58 -0400 Subject: [PATCH] fix: user image og:image --- src/controllers/topics.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/controllers/topics.js b/src/controllers/topics.js index 23a03d87e5..29167fcfb9 100644 --- a/src/controllers/topics.js +++ b/src/controllers/topics.js @@ -20,6 +20,7 @@ const activitypub = require('../activitypub'); const topicsController = module.exports; const url = nconf.get('url'); +const base_url = nconf.get('base_url'); const relative_path = nconf.get('relative_path'); const upload_url = nconf.get('upload_url'); const validSorts = ['oldest_to_newest', 'newest_to_oldest', 'most_votes']; @@ -356,8 +357,13 @@ function addOGImageTag(res, image) { } if (!imageUrl.startsWith('http')) { - // (https://domain.com/forum) + (/assets/uploads) + (/files/imagePath) - imageUrl = url + path.posix.join(upload_url, imageUrl); + if (imageUrl.startsWith(`${relative_path}${upload_url}`)) { + // (https://domain.com) + imageUrl (which starts with /relative_path/upload_url) + imageUrl = base_url + imageUrl; + } else { + // (https://domain.com/forum) + (/assets/uploads) + (/files/imagePath) + imageUrl = url + path.posix.join(upload_url, imageUrl); + } } res.locals.metaTags.push({