class OriginRequestHeaderBehavior
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.CloudFront.OriginRequestHeaderBehavior |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#OriginRequestHeaderBehavior |
![]() | software.amazon.awscdk.services.cloudfront.OriginRequestHeaderBehavior |
![]() | aws_cdk.aws_cloudfront.OriginRequestHeaderBehavior |
![]() | aws-cdk-lib » aws_cloudfront » OriginRequestHeaderBehavior |
Determines whether any HTTP headers (and if so, which headers) are included in requests that CloudFront sends to the origin.
Example
// Creating a custom origin request policy for a Distribution -- all parameters optional
declare const bucketOrigin: origins.S3Origin;
const myOriginRequestPolicy = new cloudfront.OriginRequestPolicy(this, 'OriginRequestPolicy', {
originRequestPolicyName: 'MyPolicy',
comment: 'A default policy',
cookieBehavior: cloudfront.OriginRequestCookieBehavior.none(),
headerBehavior: cloudfront.OriginRequestHeaderBehavior.all('CloudFront-Is-Android-Viewer'),
queryStringBehavior: cloudfront.OriginRequestQueryStringBehavior.allowList('username'),
});
new cloudfront.Distribution(this, 'myDistCustomPolicy', {
defaultBehavior: {
origin: bucketOrigin,
originRequestPolicy: myOriginRequestPolicy,
},
});
Properties
Name | Type | Description |
---|---|---|
behavior | string | The behavior of headers: allow all, none or an allow list. |
headers? | string[] | The headers for the allow list or the included CloudFront headers, if applicable. |
behavior
Type:
string
The behavior of headers: allow all, none or an allow list.
headers?
Type:
string[]
(optional)
The headers for the allow list or the included CloudFront headers, if applicable.
Methods
Name | Description |
---|---|
static all(...cloudfrontHeaders) | All HTTP headers in viewer requests are included in requests that CloudFront sends to the origin. |
static allow | Listed headers are included in requests that CloudFront sends to the origin. |
static deny | All headers except the provided headers are included in requests that CloudFront sends to the origin. |
static none() | HTTP headers are not included in requests that CloudFront sends to the origin. |
static all(...cloudfrontHeaders)
public static all(...cloudfrontHeaders: string[]): OriginRequestHeaderBehavior
Parameters
- cloudfrontHeaders
string
Returns
All HTTP headers in viewer requests are included in requests that CloudFront sends to the origin.
Additionally, any additional CloudFront headers provided are included; the additional headers are added by CloudFront.
See also: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-cloudfront-headers.html
static allowList(...headers)
public static allowList(...headers: string[]): OriginRequestHeaderBehavior
Parameters
- headers
string
Returns
Listed headers are included in requests that CloudFront sends to the origin.
static denyList(...headers)
public static denyList(...headers: string[]): OriginRequestHeaderBehavior
Parameters
- headers
string
Returns
All headers except the provided headers
are included in requests that CloudFront sends to the origin.
static none()
public static none(): OriginRequestHeaderBehavior
Returns
HTTP headers are not included in requests that CloudFront sends to the origin.
Any headers that are listed in a CachePolicy are still included in origin requests.