File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { MatchedRoute } from "rou3" ;
2+ import { HttpError , NotFoundHttpError } from "../errors" ;
3+ import { HttpStatus } from "../status" ;
24import type { LifeCycleHooks , RouterData , ServerSideFetch } from "../types" ;
5+ import { Context } from "./context" ;
36import {
47 cleanupCompiledWhitespace ,
58 getRawPathname ,
69 serializeErrorResponse ,
710} from "./utils" ;
8- import { Context } from "./context" ;
9- import { HttpError , NotFoundHttpError } from "../errors" ;
10- import { HttpStatus } from "../status" ;
1111
1212export function compileFetchFunction ( options : CompileOptions ) : ServerSideFetch {
1313 const onGlobalRequestCount = options . hooks . onGlobalRequest ?. length ;
@@ -144,7 +144,12 @@ function compileErrorResponse(tabs: number): string {
144144${ indent } error instanceof utils.HttpError
145145${ indent } ? error.status
146146${ indent } : utils.HttpStatus.InternalServerError;
147- ${ indent } return (ctx.response = Response.json(utils.serializeErrorResponse(error), { status }));`;
147+ ${ indent } return (
148+ ${ indent } ctx.response = Response.json(
149+ ${ indent } utils.serializeErrorResponse(error),
150+ ${ indent } { status, headers: ctx.set.headers },
151+ ${ indent } )
152+ ${ indent } );`;
148153}
149154
150155type CompileOptions = {
You can’t perform that action at this time.
0 commit comments