From fd045d9c0eeeee5ffff3b6610c3516a8d7d25b71 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 18 Mar 2026 09:49:23 +0100 Subject: [PATCH] fix(webmention-sender): fall back to siteUrl for public base URL rewriting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The livefetch patch used `process.env.PUBLICATION_URL || process.env.SITE_URL` to determine the public base URL for rewriting to INTERNAL_FETCH_URL. Neither env var is set — the publication URL comes from indiekit.config.mjs which has a hardcoded fallback. Without a publicBase, URL rewriting never fired, the public HTTPS URL was fetched directly, failed inside the FreeBSD jail, and fell back to stored content. For interaction posts (repost/bookmark/reply/like), stored content is just the body text — the target URL (repostOf, bookmarkOf, inReplyTo, likeOf) is only rendered in the live page via reply-context.njk. So 0 webmentions were sent. Fix: add `|| siteUrl` as fallback. siteUrl is already in scope (derived from `publication.me`) and is the correct value when env vars are absent. Also bump reset-stale migration to v7 so interaction posts incorrectly marked with 0 results (e.g. 342a5 repost) are reset and retried on next startup. Co-Authored-By: Claude Sonnet 4.6 --- scripts/patch-webmention-sender-livefetch.mjs | 2 +- scripts/patch-webmention-sender-reset-stale.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/patch-webmention-sender-livefetch.mjs b/scripts/patch-webmention-sender-livefetch.mjs index a23cbca8..38508127 100644 --- a/scripts/patch-webmention-sender-livefetch.mjs +++ b/scripts/patch-webmention-sender-livefetch.mjs @@ -49,7 +49,7 @@ const newBlock = ` // [patched:livefetch] Always fetch the live page so t const port = process.env.PORT || "3000"; return \`http://localhost:\${port}\`; })(); - const _publicBase = (process.env.PUBLICATION_URL || process.env.SITE_URL || "").replace(/\\/+$/, ""); + const _publicBase = (process.env.PUBLICATION_URL || process.env.SITE_URL || siteUrl || "").replace(/\\/+$/, ""); const fetchUrl = (_publicBase && postUrl.startsWith(_publicBase)) ? _internalBase + postUrl.slice(_publicBase.length) : postUrl; diff --git a/scripts/patch-webmention-sender-reset-stale.mjs b/scripts/patch-webmention-sender-reset-stale.mjs index 18b2345b..002e6e95 100644 --- a/scripts/patch-webmention-sender-reset-stale.mjs +++ b/scripts/patch-webmention-sender-reset-stale.mjs @@ -9,7 +9,7 @@ import { MongoClient } from "mongodb"; import config from "../indiekit.config.mjs"; -const MIGRATION_ID = "webmention-sender-reset-stale-v6"; +const MIGRATION_ID = "webmention-sender-reset-stale-v7"; const mongodbUrl = config.application?.mongodbUrl; if (!mongodbUrl) {