Last active
April 23, 2021 10:19
-
-
Save blackbing/a2463f3523c19e5ec8b9c201f49b304b to your computer and use it in GitHub Desktop.
Host Wildcard Subdomain in One S3 Bucket https://blackbing.medium.com/host-wildcard-subdomain-in-one-s3-bucket-with-lambda-edge-979c7cb282dc
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
exports.handler = (event, context, callback) => { | |
const request = event.Records[0].cf.request; | |
const headers = request.headers; | |
const host = headers.host[0].value; | |
const hash = /([0-9a-z-]+)\.m\.verybuy\.io/.exec(host) | |
if (hash && hash[1]) { | |
headers['X-Domain-Hash'] = [{ | |
key: "X-Domain-Hash", | |
value: hash[1], | |
}]; | |
} | |
callback(null, request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment