Skip to content

Instantly share code, notes, and snippets.

@chrismckinnel
Created June 12, 2019 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismckinnel/6aa379247b69b5488e4dcab29b254297 to your computer and use it in GitHub Desktop.
Save chrismckinnel/6aa379247b69b5488e4dcab29b254297 to your computer and use it in GitHub Desktop.
'use strict';
exports.handler = async (event) => {
console.log('Event: ', JSON.stringify(event, null, 2));
let request = event.Records[0].cf.request;
const redirects = {
'/path-1': 'https://consegna.cloud/',
'/path-2': 'https://www.amazon.com/',
};
if (redirects[request.uri]) {
return {
status: '302',
statusDescription: 'Found',
headers: {
'location': [{ value: redirects[request.uri] }]
}
};
}
return request;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment