Skip to content

Instantly share code, notes, and snippets.

@fiftin
Last active November 21, 2020 14:35
Show Gist options
  • Save fiftin/40196db7ed2956855b978a8562e2bf75 to your computer and use it in GitHub Desktop.
Save fiftin/40196db7ed2956855b978a8562e2bf75 to your computer and use it in GitHub Desktop.
AWS Lambda for implementing static site with using S3 and CloudFront.
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