Last active
March 7, 2022 06:03
-
-
Save blackbing/af573407e1e3905a0fc934239443552c 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 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 headers = request.headers; | |
const domainHash = headers['x-domain-hash'] && headers['x-domain-hash'][0].value; | |
if (domainHash) { | |
request.uri = '/' + domainHash + request.uri; | |
} | |
return callback(null, request); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment