Skip to content

Commit 2174ef0

Browse files
committed
fix: host header must be correctly set for S3 origin
1 parent 91b8c67 commit 2174ef0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lambda/router.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export async function handler(event, context, callback) {
2020
}
2121

2222
if (staticFiles.includes(uri)) {
23+
request = await performReWrite(uri, request)
2324
callback(null, request)
2425
return
2526
}
@@ -51,6 +52,9 @@ async function performReWrite(uri, request, target) {
5152
request.uri = uri
5253

5354
if (typeof target === 'undefined') {
55+
request.headers['host'] = [
56+
{ key: 'host', value: request.origin.s3.domainName },
57+
]
5458
return request
5559
}
5660

0 commit comments

Comments
 (0)