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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "Allow get requests originating from example.com and *.example.com", | |
| "Effect": "Allow", | |
| "Principal": "*", | |
| "Action": "s3:GetObject", | |
| "Resource": "arn:aws:s3:::example.com/*", | |
| "Condition": { |
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
| module.exports = [ | |
| { product: "kimchibeanz", origin: "example-1.s3-website-us-east-1.amazonaws.com" }, | |
| { product: "durianshakez", origin: "example-2.s3-website-us-east-1.amazonaws.com" }, | |
| { product: "example", origin: "example-3.s3-website-us-east-1.amazonaws.com" } | |
| // "example" is for when someone makes a request to https://example.com. | |
| ]; |
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
| // Import the data that maps the origins to each product. | |
| const bucketData = require("./bucketData.js"); | |
| exports.handler = (event, context, callback) => { | |
| // Get the request object. | |
| const request = event.Records[0].cf.request; | |
| // Get the host from the request and take out "www." from the host if it exists. | |
| let host = request.headers.host[0].value; |
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) => { | |
| // Get the request object. | |
| const request = event.Records[0].cf.request; | |
| // Get the host from the request and take out "www." from the host if it exists. | |
| let host = request.headers.host[0].value; | |
| host = host.replace(/^www\./, ""); | |
| // Check if the host contains a subdomain. |