fix: remove endpoint-auth well-known handler; Mastodon router wins
Deploy Indiekit Server / deploy (push) Successful in 1m24s

/.well-known/oauth-authorization-server was returning IndieAuth metadata
(/auth endpoint) instead of Mastodon OAuth metadata (/oauth/authorize).
Removing the conflicting endpoint-auth registration lets the Mastodon
router serve the correct metadata for clients like Mona.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Sven
2026-04-28 15:58:26 +02:00
parent bc44dda3e4
commit cc843d34c5
+32
View File
@@ -0,0 +1,32 @@
/**
* Patch @indiekit/endpoint-auth to remove its /.well-known/oauth-authorization-server
* handler so the Mastodon router's handler (with correct /oauth/authorize endpoint)
* takes precedence. endpoint-auth registers first in Express, winning over the
* Mastodon router — this removes the conflicting registration.
*/
import { readFileSync, writeFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { join, dirname } from "node:path";
const __dirname = dirname(fileURLToPath(import.meta.url));
const pkg = join(__dirname, "../node_modules/@indiekit/endpoint-auth/index.js");
let src = readFileSync(pkg, "utf-8");
const MARKER = "// patch-mastodon-well-known: removed";
if (src.includes(MARKER)) {
console.log("[patch-mastodon-well-known] Already applied");
process.exit(0);
}
const OLD = `router.get("/oauth-authorization-server", metadataController);`;
const NEW = `${MARKER}`;
if (!src.includes(OLD)) {
console.error("[patch-mastodon-well-known] Target line not found — check endpoint-auth version");
process.exit(1);
}
src = src.replace(OLD, NEW);
writeFileSync(pkg, src, "utf-8");
console.log("[patch-mastodon-well-known] Removed endpoint-auth well-known handler; Mastodon router takes over");