fix(webmention-sender): fall back to siteUrl for public base URL rewriting

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 <noreply@anthropic.com>
This commit is contained in:
Sven
2026-03-18 09:49:23 +01:00
parent 059f36bf06
commit fd045d9c0e
2 changed files with 2 additions and 2 deletions

View File

@@ -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;