Skip to content

Commit 43fa62c

Browse files
fix: rewrite markdown doc requests internally instead of 303 redirect (#808)
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 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 202961c commit 43fa62c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/server.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ export default createServerEntry(
2828
url.pathname.includes('/docs/') &&
2929
!url.pathname.endsWith('.md')
3030
) {
31-
logRequestEnd(context, 303, { redirectToMarkdown: true })
32-
return new Response(null, {
33-
status: 303,
34-
headers: {
35-
Location: `${url.pathname}.md`,
36-
},
31+
const mdUrl = new URL(request.url)
32+
mdUrl.pathname = `${url.pathname}.md`
33+
const mdRequest = new Request(mdUrl, request)
34+
const mdResponse = await handler.fetch(mdRequest)
35+
logRequestEnd(context, mdResponse.status, {
36+
rewrittenToMarkdown: true,
3737
})
38+
return mdResponse
3839
}
3940

4041
const response = await handler.fetch(request)

0 commit comments

Comments
 (0)