File tree Expand file tree Collapse file tree
src/routes/chat-completions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,13 @@ function handleFetchError(
5151 c : Context < BlankEnv , "/" , BlankInput > ,
5252 error : FetchError ,
5353) {
54+ const status = error . response ?. status ?? 500
55+
56+ // Forward all headers from the error response
57+ error . response ?. headers . forEach ( ( value , key ) => {
58+ c . header ( key , value )
59+ } )
60+
5461 return c . json (
5562 {
5663 error : {
@@ -59,7 +66,7 @@ function handleFetchError(
5966 data : error . response ?. _data as unknown ,
6067 } ,
6168 } ,
62- ( error . response ?. status ?? 500 ) as ContentfulStatusCode ,
69+ status as ContentfulStatusCode ,
6370 )
6471}
6572
@@ -72,6 +79,11 @@ async function handleResponseError(
7279 `Request failed: ${ error . status } ${ error . statusText } : ${ errorText } ` ,
7380 )
7481
82+ // Forward all headers from the error response
83+ error . headers . forEach ( ( value , key ) => {
84+ c . header ( key , value )
85+ } )
86+
7587 return c . json (
7688 {
7789 error : {
You can’t perform that action at this time.
0 commit comments