Skip to content

Commit 817091a

Browse files
zfy0701claude
andauthored
fix(llms): give llms.txt absolute links on the requesting origin (#27)
The index linked pages root-relatively, so a copy of llms.txt handed to a model or fetched on its own pointed nowhere. Build each link from the request's origin instead, which keeps the repository free of channel hostnames and serves every channel its own links. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 6c908c7 commit 817091a

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎app/llms.txt/route.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import { llms } from 'fumadocs-core/source'
22
import { BASE_PATH } from '@/base-path.mjs'
33
import { reference, source } from '@/lib/source'
44

5-
export const dynamic = 'force-static'
6-
7-
// The llms.txt index: every guide and API operation with its URL, which page URLs give without the base path.
8-
export async function GET() {
5+
// The llms.txt index: every guide and API operation with an absolute URL on the origin it was requested from.
6+
export async function GET(request: Request) {
97
const [guides, api] = await Promise.all([llms(source).index(), llms(reference).index()])
10-
const body = `# AgentConnect\n\n${guides}\n\n${api}\n`.replaceAll('](/', `](${BASE_PATH}/`)
8+
const root = `${new URL(request.url).origin}${BASE_PATH}`
9+
const body = `# AgentConnect\n\n${guides}\n\n${api}\n`.replaceAll('](/', `](${root}/`)
1110
return new Response(body, { headers: { 'content-type': 'text/plain; charset=utf-8' } })
1211
}

0 commit comments

Comments
 (0)