OriginRequestHeaderBehavior Class
Determines whether any HTTP headers (and if so, which headers) are included in requests that CloudFront sends to the origin.
Example
ts
// 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
The behavior of headers: allow all, none or an allow list.
headersmay be undefinedstring[]headersmay be undefinedtyping.List[str]headersmay be undefinedList<String>Headersmay be undefinedstring[]Headersmay be undefined*[]*string#The headers for the allow list or the included CloudFront headers, if applicable.
Methods
all(...cloudfrontHeaders: string[]): OriginRequestHeaderBehavior // chainable@staticmethod def all(cloudfront_headers: str) -> OriginRequestHeaderBehaviorpublic static OriginRequestHeaderBehavior all(String cloudfrontHeaders)public static OriginRequestHeaderBehavior All(string cloudfrontHeaders)func All(CloudfrontHeaders *string) OriginRequestHeaderBehaviorstatic#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.
allowList(...headers: string[]): OriginRequestHeaderBehavior // chainable@staticmethod def allow_list(headers: str) -> OriginRequestHeaderBehaviorpublic static OriginRequestHeaderBehavior allowList(String headers)public static OriginRequestHeaderBehavior AllowList(string headers)func AllowList(Headers *string) OriginRequestHeaderBehaviorstatic#Listed headers are included in requests that CloudFront sends to the origin.
denyList(...headers: string[]): OriginRequestHeaderBehavior // chainable@staticmethod def deny_list(headers: str) -> OriginRequestHeaderBehaviorpublic static OriginRequestHeaderBehavior denyList(String headers)public static OriginRequestHeaderBehavior DenyList(string headers)func DenyList(Headers *string) OriginRequestHeaderBehaviorstatic#All headers except the provided `headers` are included in requests that CloudFront sends to the origin.
none(): OriginRequestHeaderBehavior // chainable@staticmethod def none() -> OriginRequestHeaderBehaviorpublic static OriginRequestHeaderBehavior none()public static OriginRequestHeaderBehavior None()func None() OriginRequestHeaderBehaviorstatic#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.