Last active
October 14, 2019 15:59
-
-
Save jebai0521/332f58e1569347aa2dc2d41aeaa4bb21 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
const s3DomainName = 'static-jebai.s3.amazonaws.com'; | |
const countryCode = request.headers['cloudfront-viewer-country'][0].value.toLowerCase(); | |
request.origin = { | |
s3: { | |
domainName: s3DomainName, | |
region: '', | |
authMethod: 'none', | |
path: "/" + countryCode, | |
customHeaders: {} | |
} | |
} | |
request.headers['host'] = [{ key: 'host', value: s3DomainName }]; | |
callback(null, request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment