@@ -124,7 +124,6 @@ export async function handleServerFunction(h3Event: H3Event) {
124124 h3Event . res . headers . set ( "content-type" , "text/javascript" ) ;
125125 return serializeToJSStream ( instance , result ) ;
126126 }
127- h3Event . res . headers . set ( "content-type" , "text/plain" ) ;
128127 return serializeToJSONStream ( result ) ;
129128 } catch ( x ) {
130129 if ( x instanceof Response ) {
@@ -134,14 +133,18 @@ export async function handleServerFunction(h3Event: H3Event) {
134133 // forward headers
135134 if ( ( x as any ) . headers ) mergeResponseHeaders ( h3Event , ( x as any ) . headers ) ;
136135 // forward non-redirect statuses
137- if ( ( x as any ) . status && ( ! instance || ( x as any ) . status < 300 || ( x as any ) . status >= 400 ) )
136+ if (
137+ ( x as any ) . status &&
138+ ( ! instance || ( x as any ) . status < 300 || ( x as any ) . status >= 400 )
139+ )
138140 h3Event . res . status = ( x as any ) . status ;
139141 if ( ( x as any ) . customBody ) {
140142 x = await ( x as any ) . customBody ( ) ;
141143 } else if ( ( x as any ) . body == null ) x = null ;
142144 h3Event . res . headers . set ( "X-Error" , "true" ) ;
143145 } else if ( instance ) {
144- const error = x instanceof Error ? x . message : typeof x === "string" ? x : "true" ;
146+ const error =
147+ x instanceof Error ? x . message : typeof x === "string" ? x : "true" ;
145148
146149 h3Event . res . headers . set ( "X-Error" , toHeaderValue ( error ) ) ;
147150 } else {
@@ -164,7 +167,6 @@ export async function handleServerFunction(h3Event: H3Event) {
164167 h3Event . res . headers . set ( "content-type" , "text/javascript" ) ;
165168 return serializeToJSStream ( instance , x ) ;
166169 }
167- h3Event . res . headers . set ( "content-type" , "text/plain" ) ;
168170 return serializeToJSONStream ( x ) ;
169171 }
170172 return x ;
@@ -192,7 +194,10 @@ function handleNoJS(result: any, request: Request, parsed: any[], thrown?: boole
192194 if ( result . headers . has ( "Location" ) ) {
193195 headers . set (
194196 `Location` ,
195- new URL ( result . headers . get ( "Location" ) ! , url . origin + import . meta. env . BASE_URL ) . toString ( ) ,
197+ new URL (
198+ result . headers . get ( "Location" ) ! ,
199+ url . origin + import . meta. env . BASE_URL ,
200+ ) . toString ( ) ,
196201 ) ;
197202 statusCode = getExpectedRedirectStatus ( result ) ;
198203 }
@@ -209,7 +214,10 @@ function handleNoJS(result: any, request: Request, parsed: any[], thrown?: boole
209214 result : isError ? result . message : result ,
210215 thrown : thrown ,
211216 error : isError ,
212- input : [ ...parsed . slice ( 0 , - 1 ) , [ ...parsed [ parsed . length - 1 ] . entries ( ) ] ] ,
217+ input : [
218+ ...parsed . slice ( 0 , - 1 ) ,
219+ [ ...parsed [ parsed . length - 1 ] . entries ( ) ] ,
220+ ] ,
213221 } ) ,
214222 ) } ; Secure; HttpOnly;`,
215223 ) ;
@@ -235,7 +243,7 @@ export function createSingleFlightHeaders(sourceEvent: FetchEvent) {
235243 // useH3Internals = true;
236244 // sourceEvent.nativeEvent.node.req.headers.cookie = "";
237245 // }
238- SetCookies . forEach ( cookie => {
246+ SetCookies . forEach ( ( cookie ) => {
239247 if ( ! cookie ) return ;
240248 const { maxAge, expires, name, value } = parseSetCookie ( cookie ) ;
241249 if ( maxAge != null && maxAge <= 0 ) {
@@ -256,7 +264,10 @@ export function createSingleFlightHeaders(sourceEvent: FetchEvent) {
256264
257265 return headers ;
258266}
259- async function handleSingleFlight ( sourceEvent : FetchEvent , result : any ) : Promise < Response > {
267+ async function handleSingleFlight (
268+ sourceEvent : FetchEvent ,
269+ result : any ,
270+ ) : Promise < Response > {
260271 let revalidate : string [ ] ;
261272 let url = new URL ( sourceEvent . request . headers . get ( "referer" ) ! ) . toString ( ) ;
262273 if ( result instanceof Response ) {
0 commit comments