Last active
November 21, 2020 14:35
-
-
Save fiftin/40196db7ed2956855b978a8562e2bf75 to your computer and use it in GitHub Desktop.
AWS Lambda for implementing static site with using S3 and CloudFront.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
exports.handler = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
if (!path.extname(request.uri)) { | |
if (!request.uri.endsWith('/')) { | |
request.uri += '/'; | |
} | |
request.uri += 'index.html'; | |
} | |
callback(null, request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment