Skip to content

Commit 67bd90a

Browse files
committed
update lambda and workflow to handle secure s3 bucket
Signed-off-by: CrazyMax <[email protected]>
1 parent 41810b9 commit 67bd90a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ jobs:
100100
if: ${{ env.DOCS_S3_BUCKET != '' }}
101101
run: |
102102
aws --region ${{ env.DOCS_AWS_REGION }} s3 sync \
103-
--acl public-read \
104103
--delete \
105104
--exclude "*" \
106105
--include "*.webp" \
@@ -109,7 +108,6 @@ jobs:
109108
--content-type="image/webp" \
110109
public s3://${{ env.DOCS_S3_BUCKET }}/
111110
aws --region ${{ env.DOCS_AWS_REGION }} s3 sync \
112-
--acl public-read \
113111
--delete \
114112
--exclude "*.webp" \
115113
public s3://${{ env.DOCS_S3_BUCKET }}/

hack/releaser/cloudfront-lambda-redirects.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,22 @@ exports.handler = (event, context, callback) => {
5252
return
5353
}
5454

55+
// Handle directory requests by appending index.html for requests without file extensions
56+
let uri = request.uri;
57+
58+
// Check if the URI has a dot after the last slash (indicating a filename)
59+
// This is more accurate than just checking the end of the URI
60+
const hasFileExtension = /\.[^/]*$/.test(uri.split('/').pop());
61+
62+
// If it's not a file, treat it as a directory and append index.html
63+
if (!hasFileExtension) {
64+
// Ensure the URI ends with a slash before appending index.html
65+
if (!uri.endsWith("/")) {
66+
uri += "/";
67+
}
68+
uri += "index.html";
69+
request.uri = uri;
70+
}
71+
5572
callback(null, request);
5673
};

0 commit comments

Comments
 (0)