From 8ce5498f2351bf513f295d25441e20e56d9dd051 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Sat, 2 Aug 2025 09:48:59 -0400 Subject: [PATCH] fix: add rel canonical to remote user profiles --- src/controllers/accounts/profile.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js index b22e6eb73c..de0e744eb5 100644 --- a/src/controllers/accounts/profile.js +++ b/src/controllers/accounts/profile.js @@ -52,6 +52,10 @@ profileController.get = async function (req, res, next) { if (meta.config.activitypubEnabled) { // Include link header for richer parsing res.set('Link', `<${nconf.get('url')}/uid/${userData.uid}>; rel="alternate"; type="application/activity+json"`); + + if (!utils.isNumber(userData.uid)) { + res.set('Link', `<${userData.url || userData.uid}>; rel="canonical"`); + } } res.render('account/profile', userData); @@ -174,5 +178,12 @@ function addTags(res, userData) { type: 'application/activity+json', href: `${nconf.get('url')}/uid/${userData.uid}`, }); + + if (!utils.isNumber(userData.uid)) { + res.locals.linkTags.push({ + rel: 'canonical', + href: userData.url || userData.uid, + }); + } } }