From f19f7e17413b4e6b2a3c4c60a1faa7ec99143b18 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 18:51:16 +0000 Subject: [PATCH] fix(ap): correct webfinger patch snippet to match current fork (318720c) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The OLD_SNIPPET had wrong indentation (8 spaces vs 6) and was missing the method guard line added in the fork: if (req.method !== "GET" && req.method !== "HEAD") return next(); Without this fix the patch silently skips patching and webfinger continues to return 302 → 401 on fediverse delivery. https://claude.ai/code/session_0124D41vdLYE3DkJxhPqYthX --- scripts/patch-ap-webfinger-before-auth.mjs | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/scripts/patch-ap-webfinger-before-auth.mjs b/scripts/patch-ap-webfinger-before-auth.mjs index 13d0f89e..2cfd033f 100644 --- a/scripts/patch-ap-webfinger-before-auth.mjs +++ b/scripts/patch-ap-webfinger-before-auth.mjs @@ -30,26 +30,30 @@ const candidates = [ const MARKER = "// ap-webfinger-before-auth patch"; -const OLD_SNIPPET = ` // Only delegate to Fedify for NodeInfo data endpoint (/nodeinfo/2.1). - // All other paths in this root-mounted router are handled by the - // content negotiation catch-all below. Passing arbitrary paths like - // /notes/... to Fedify causes harmless but noisy 404 warnings. - if (!req.path.startsWith("/nodeinfo/")) return next(); - return self._fedifyMiddleware(req, res, next);`; +const OLD_SNIPPET = ` if (!self._fedifyMiddleware) return next(); + if (req.method !== "GET" && req.method !== "HEAD") return next(); + // Only delegate to Fedify for NodeInfo data endpoint (/nodeinfo/2.1). + // All other paths in this root-mounted router are handled by the + // content negotiation catch-all below. Passing arbitrary paths like + // /notes/... to Fedify causes harmless but noisy 404 warnings. + if (!req.path.startsWith("/nodeinfo/")) return next(); + return self._fedifyMiddleware(req, res, next);`; -const NEW_SNIPPET = ` // Delegate to Fedify for discovery endpoints: - // /.well-known/webfinger — actor/resource identity resolution - // /.well-known/nodeinfo — server capabilities advertised to the fediverse - // /nodeinfo/2.1 — NodeInfo data document - // This router is mounted at "/" so req.url retains the full path, allowing - // Fedify to match its internal routes correctly. (routesWellKnown strips - // the /.well-known/ prefix, causing Fedify to miss the webfinger route.) - // ap-webfinger-before-auth patch - const isDiscoveryRoute = - req.path.startsWith("/nodeinfo/") || - req.path.startsWith("/.well-known/"); - if (!isDiscoveryRoute) return next(); - return self._fedifyMiddleware(req, res, next);`; +const NEW_SNIPPET = ` if (!self._fedifyMiddleware) return next(); + if (req.method !== "GET" && req.method !== "HEAD") return next(); + // Delegate to Fedify for discovery endpoints: + // /.well-known/webfinger — actor/resource identity resolution + // /.well-known/nodeinfo — server capabilities advertised to the fediverse + // /nodeinfo/2.1 — NodeInfo data document + // This router is mounted at "/" so req.url retains the full path, allowing + // Fedify to match its internal routes correctly. (routesWellKnown strips + // the /.well-known/ prefix, causing Fedify to miss the webfinger route.) + // ap-webfinger-before-auth patch + const isDiscoveryRoute = + req.path.startsWith("/nodeinfo/") || + req.path.startsWith("/.well-known/"); + if (!isDiscoveryRoute) return next(); + return self._fedifyMiddleware(req, res, next);`; async function exists(filePath) { try {