Skip to content

Commit 4527bf0

Browse files
committed
fix(addCORSHeaders): add Access-Control-Expose-Headers for custom headers
1 parent 2fa5a06 commit 4527bf0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/addCORSHeaders.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import type {
66

77
export const addCORSHeaders = (
88
AccessControlAllowOrigin: string = '*',
9+
AccessControlExposeHeaders: Array<string> = [
10+
'x-amzn-requestid',
11+
'etag',
12+
'apigw-requestid',
13+
],
914
): MiddlewareObj<APIGatewayProxyEventV2, APIGatewayProxyStructuredResultV2> => {
1015
const setCORSHeaders = async (req: Request) => {
1116
if (req.response === null) return
@@ -14,6 +19,7 @@ export const addCORSHeaders = (
1419
headers: {
1520
...(req.response.headers ?? {}),
1621
'Access-Control-Allow-Origin': AccessControlAllowOrigin,
22+
'Access-Control-Expose-Headers': AccessControlExposeHeaders.join(', '),
1723
},
1824
}
1925
}

0 commit comments

Comments
 (0)