@@ -5,7 +5,6 @@ import { get } from 'lodash-es'
55
66import getMiniTocItems from '@/frame/lib/get-mini-toc-items'
77import patterns from '@/frame/lib/patterns'
8- import { pathLanguagePrefixed } from '@/languages/lib/languages'
98import FailBot from '@/observability/lib/failbot'
109import statsd from '@/observability/lib/statsd'
1110import type { ExtendedRequest } from '@/types'
@@ -16,7 +15,6 @@ import { isConnectionDropped } from './halt-on-dropped-connection'
1615import { nextHandleRequest } from './next'
1716
1817const STATSD_KEY_RENDER = 'middleware.render_page'
19- const STATSD_KEY_404 = 'middleware.render_404'
2018
2119async function buildRenderedPage ( req : ExtendedRequest ) : Promise < string > {
2220 const { context } = req
@@ -69,33 +67,10 @@ export default async function renderPage(req: ExtendedRequest, res: Response) {
6967 )
7068 }
7169
72- if ( ! pathLanguagePrefixed ( req . path ) ) {
73- defaultCacheControl ( res )
74- return res . status ( 404 ) . type ( 'html' ) . send ( minimumNotFoundHtml )
75- }
76-
77- // For App Router migration: All language-prefixed 404s should use App Router
78- statsd . increment ( STATSD_KEY_404 , 1 , [
79- `url:${ req . url } ` ,
80- `path:${ req . path } ` ,
81- `referer:${ req . headers . referer || '' } ` ,
82- ] )
83-
70+ // send minimal 404 at this point since we ran into hydration issues trying to pass
71+ // these along to AppRouter 404 handling
8472 defaultCacheControl ( res )
85-
86- // Create a mock request that will be handled by App Router
87- const mockReq = Object . create ( req )
88- mockReq . url = '/404'
89- mockReq . path = '/404'
90- mockReq . method = 'GET'
91-
92- // Only pass pathname
93- res . setHeader ( 'x-pathname' , req . path )
94-
95- // Import nextApp and handle directly
96- const { nextApp } = await import ( './next' )
97- res . status ( 404 )
98- return nextApp . getRequestHandler ( ) ( mockReq , res )
73+ return res . status ( 404 ) . type ( 'html' ) . send ( minimumNotFoundHtml )
9974 }
10075
10176 // Just finish fast without all the details like Content-Length
0 commit comments