@@ -14,7 +14,8 @@ export const handler = WrapError(async (event: APIGatewayProxyEventV2): Promise<
14
14
if ( event . rawPath === '/' || event . rawPath === '/ping' ) {
15
15
return resp ( 200 , 'ok' ) ;
16
16
} else if ( event . rawPath === '/_debug' ) {
17
- return resp ( 400 , debug ( ) ) ;
17
+ console . log ( debug ( ) ) ;
18
+ return resp ( 400 , 'Please check your server logs for more details!' ) ;
18
19
}
19
20
20
21
const accept = event . headers . Accept ?? event . headers . accept ?? '' ;
@@ -31,11 +32,11 @@ export const handler = WrapError(async (event: APIGatewayProxyEventV2): Promise<
31
32
context . features [ Features . AutoWebp ] = autoWebp ;
32
33
const { data, type } = await processor . process ( context ) ;
33
34
34
- return resp ( 200 , data , type ) ;
35
+ return resp ( 200 , data , type , context . headers ) ;
35
36
} else {
36
- const { buffer, type } = await bs . get ( uri , bypass ) ;
37
+ const { buffer, type, headers } = await bs . get ( uri , bypass ) ;
37
38
38
- return resp ( 200 , buffer , type ) ;
39
+ return resp ( 200 , buffer , type , headers ) ;
39
40
}
40
41
} ) ;
41
42
@@ -44,7 +45,7 @@ function bypass() {
44
45
throw new HttpErrors [ 403 ] ( 'Please visit s3 directly' ) ;
45
46
}
46
47
47
- function resp ( code : number , body : any , type ?: string ) : APIGatewayProxyResultV2 {
48
+ function resp ( code : number , body : any , type ?: string , headers ?: { [ key : string ] : any } ) : APIGatewayProxyResultV2 {
48
49
const isBase64Encoded = Buffer . isBuffer ( body ) ;
49
50
let data : string = '' ;
50
51
if ( isBase64Encoded ) {
@@ -60,7 +61,7 @@ function resp(code: number, body: any, type?: string): APIGatewayProxyResultV2 {
60
61
return {
61
62
isBase64Encoded,
62
63
statusCode : code ,
63
- headers : { 'Content-Type' : type ?? 'text/plain' } ,
64
+ headers : Object . assign ( { 'Content-Type' : type ?? 'text/plain' } , headers ) ,
64
65
body : data ,
65
66
} ;
66
67
}
0 commit comments