File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ const handleAIClientRedirect = (request: NextRequest) => {
5959 const userAgent = request . headers . get ( 'user-agent' ) || '' ;
6060 const url = request . nextUrl ;
6161
62+ // Log user agent for debugging (only for non-static assets)
63+ if ( ! url . pathname . startsWith ( '/_next/' ) &&
64+ ! url . pathname . includes ( '.' ) &&
65+ ! url . pathname . startsWith ( '/api/' ) ) {
66+ console . log ( `[Middleware] ${ url . pathname } - User-Agent: ${ userAgent } ` ) ;
67+ }
68+
6269 // Skip if already requesting a markdown file
6370 if ( url . pathname . endsWith ( '.md' ) ) {
6471 return undefined ;
@@ -76,6 +83,9 @@ const handleAIClientRedirect = (request: NextRequest) => {
7683 const isAIClient = isAIOrDevTool ( userAgent ) ;
7784
7885 if ( isAIClient || forceMarkdown ) {
86+ // Log the redirect for debugging
87+ console . log ( `[Middleware] Redirecting to markdown: ${ isAIClient ? 'AI client detected' : 'Manual format=md' } ` ) ;
88+
7989 // Create new URL with .md extension
8090 const newUrl = url . clone ( ) ;
8191 // Handle root path and ensure proper .md extension
You can’t perform that action at this time.
0 commit comments