@@ -19,11 +19,7 @@ export const config = {
1919
2020// This function can be marked `async` if using `await` inside
2121export function middleware ( request : NextRequest ) {
22- // Check if the URL ends with llms.txt
23- if ( request . nextUrl . pathname . endsWith ( 'llms.txt' ) ) {
24- return handleLlmsTxt ( request ) ;
25- }
26-
22+ // Remove the llms.txt handling - it's now handled by Next.js redirects
2723 return handleRedirects ( request ) ;
2824}
2925
@@ -67,32 +63,6 @@ const handleRedirects = (request: NextRequest) => {
6763 return undefined ;
6864} ;
6965
70- const handleLlmsTxt = async ( request : NextRequest ) => {
71- try {
72- // Get the original path by removing llms.txt
73- const originalPath = request . nextUrl . pathname . replace ( / \/ l l m s \. t x t $ / , '' ) || '/' ;
74- const pathSegments = originalPath . split ( '/' ) . filter ( Boolean ) ;
75-
76- // Rewrite to the API route with path segments
77- const apiPath =
78- pathSegments . length > 0
79- ? `/api/llms-txt/${ pathSegments . join ( '/' ) } `
80- : '/api/llms-txt' ;
81-
82- const apiUrl = new URL ( apiPath , request . url ) ;
83-
84- return NextResponse . rewrite ( apiUrl ) ;
85- } catch ( error ) {
86- console . error ( 'Error handling llms.txt rewrite:' , error ) ;
87- return new Response ( 'Error processing request' , {
88- status : 500 ,
89- headers : {
90- 'Content-Type' : 'text/plain; charset=utf-8' ,
91- } ,
92- } ) ;
93- }
94- } ;
95-
9666type Redirect = {
9767 /** a string with a leading and a trailing slash */
9868 from : `/${string } /` | '/' ;
0 commit comments