From 0eb48fc58877572d4101014574382c6e007c0eca Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Apr 2026 21:01:16 +0000 Subject: [PATCH] fix: rewrite markdown doc requests internally instead of 303 redirect Agents requesting docs with Accept: text/markdown were getting 303 redirects to .md URLs, which many HTTP clients don't follow properly. Instead of redirecting, internally rewrite the request to the .md route and serve the markdown content directly. https://claude.ai/code/session_01VBx5hnhWturAn1bBo68sCt --- src/server.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/server.ts b/src/server.ts index f8ed98bd0..1c1a6165a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -28,13 +28,14 @@ export default createServerEntry( url.pathname.includes('/docs/') && !url.pathname.endsWith('.md') ) { - logRequestEnd(context, 303, { redirectToMarkdown: true }) - return new Response(null, { - status: 303, - headers: { - Location: `${url.pathname}.md`, - }, + const mdUrl = new URL(request.url) + mdUrl.pathname = `${url.pathname}.md` + const mdRequest = new Request(mdUrl, request) + const mdResponse = await handler.fetch(mdRequest) + logRequestEnd(context, mdResponse.status, { + rewrittenToMarkdown: true, }) + return mdResponse } const response = await handler.fetch(request)