Created
June 12, 2019 09:20
-
-
Save chrismckinnel/6aa379247b69b5488e4dcab29b254297 to your computer and use it in GitHub Desktop.
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
'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