Files
better-auth/docs/proxy.ts
KinfeMichael Tariku abef2e9207 docs: bump to next.js 16 (#5276)
Co-authored-by: Alex Yang <himself65@outlook.com>
2025-10-13 16:32:02 +00:00

21 lines
530 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { isMarkdownPreferred, rewritePath } from "fumadocs-core/negotiation";
const { rewrite: rewriteLLM } = rewritePath("/docs/*path", "/llms.txt/*path");
export function proxy(request: NextRequest) {
if (isMarkdownPreferred(request)) {
const result = rewriteLLM(request.nextUrl.pathname);
if (result) {
return NextResponse.rewrite(new URL(result, request.nextUrl));
}
}
return NextResponse.next();
}
export const config = {
matcher: "/docs/:path*",
};