Skip to content

Node.js based forum software built for the modern web

feat: redirect cold requests to remote resources to their canonical source, #14043

Julian Lam2b12f8b5787f
diff --git a/src/controllers/accounts/profile.js b/src/controllers/accounts/profile.js
index fab317fe17..21f6e6a191 100644
--- a/src/controllers/accounts/profile.js
+++ b/src/controllers/accounts/profile.js
@@ -24,6 +24,10 @@ profileController.get = async function (req, res, next) {
return next();
}
+ if (meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(userData.uid)) {
+ return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(userData.uid)}`);
+ }
+
await incrementProfileViews(req, userData);
const [latestPosts, bestPosts, customUserFields] = await Promise.all([
diff --git a/src/controllers/posts.js b/src/controllers/posts.js
index 44f2b06649..ed37f0e659 100644
--- a/src/controllers/posts.js
+++ b/src/controllers/posts.js
@@ -19,12 +19,16 @@ postsController.redirectToPost = async function (req, res, next) {
return next();
}
- // Kickstart note assertion if applicable
- if (!utils.isNumber(pid) && req.uid && meta.config.activitypubEnabled) {
- const exists = await posts.exists(pid);
- if (!exists) {
- await activitypub.notes.assert(req.uid, pid);
- }
+ // Kickstart note assertion if applicable -- might not be needed, if no ill effects, remove 1 Apr 2026
+ // if (!utils.isNumber(pid) && req.uid && meta.config.activitypubEnabled) {
+ // const exists = await posts.exists(pid);
+ // if (!exists) {
+ // await activitypub.notes.assert(req.uid, pid);
+ // }
+ // }
+
+ if (meta.config.activitypubEnabled && !res.locals.isAPI && !utils.isNumber(pid)) {
+ return helpers.redirect(res, `/outgoing?url=${encodeURIComponent(pid)}`);
}
const [canRead, path] = await Promise.all([