File tree Expand file tree Collapse file tree
packages/start/src/server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,14 +77,21 @@ export function createBaseHandler(
7777 return html ;
7878 }
7979
80- const stream = renderToStream ( ( ) => {
80+ const _stream = renderToStream ( ( ) => {
8181 ( sharedConfig . context as any ) . event = context ;
8282 return fn ( context ) ;
8383 } , resolvedOptions ) ;
84+ const stream = _stream as typeof _stream & Promise < string > // stream has a hidden 'then' method
85+
86+ if ( event . request . headers . get ( "x-nitro-prerender" ) ) {
87+ const _html = await stream ;
88+ const html = _html . replaceAll ( / d a t a - h k = ( \d + ) (? = \s | > ) / g, 'data-hk="$1"' ) ;
89+ return html
90+ }
8491
8592 // insert redirect handling here
8693
87- if ( mode === "async" ) return stream as unknown as Promise < string > ; // stream has a hidden 'then' method
94+ if ( mode === "async" ) return stream
8895
8996 const { writable, readable } = new TransformStream ( ) ;
9097 stream . pipeTo ( writable ) ;
You can’t perform that action at this time.
0 commit comments