Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private addCloudfront() {
const name = `${this.name}CFD`
const originPath = this.apiGatewayOriginPath
const allowedMethods = CF.CloudFrontAllowedMethods.ALL
const behaviors = [{ allowedMethods, isDefaultBehavior: true }]
const customOriginSource = { domainName: this.apiGatewayDomain }
const originConfigs = [{ behaviors, customOriginSource, originPath }]
const conf = { defaultRootObject: '', originConfigs }
// tslint:disable-next-line:no-unused-expression
new CF.CloudFrontWebDistribution(this, name, conf)
}
}
getDefaultBehavior() {
return {
allowedMethods: CF.CloudFrontAllowedMethods.ALL,
compress: true,
forwardedValues: { headers: ['authorization'], queryString: true },
isDefaultBehavior: true,
}
}
getErrorPageConfig(bucket: S3.Bucket): CF.SourceConfiguration {
const errorBehavior: CF.Behavior = {
allowedMethods: CF.CloudFrontAllowedMethods.ALL,
compress: true,
forwardedValues: { headers: ['authorization'], queryString: true },
isDefaultBehavior: false,
pathPattern: '/error*',
}
const s3OriginConfig: CF.S3OriginConfig = {
s3BucketSource: bucket,
}
const errorPageConfig: CF.SourceConfiguration = {
behaviors: [errorBehavior],
s3OriginSource: s3OriginConfig,
}
return errorPageConfig