Skip to content

Instantly share code, notes, and snippets.

@maheee
Created May 11, 2019 17:29
Show Gist options
  • Save maheee/6e6f07c661e8785f0c2e33ea17c07965 to your computer and use it in GitHub Desktop.
Save maheee/6e6f07c661e8785f0c2e33ea17c07965 to your computer and use it in GitHub Desktop.
lambda redirect
exports.handler = (event, context, callback) => {
var request = event.Records[0].cf.request;
var olduri = request.uri;
var newuri = olduri;
newuri = newuri.replace(/^\/$/, '\/index.html');
newuri = newuri.replace(/^\/dashboard\/$/, '\/dashboard\/dash.html');
console.log("Old URI: " + olduri);
console.log("New URI: " + newuri);
request.uri = newuri;
return callback(null, request);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment