From faa19f8d1fbebe5cfe4242c1585aa3a9f7090102 Mon Sep 17 00:00:00 2001 From: finnholland <65142636+finnholland@users.noreply.github.com> Date: Fri, 25 Oct 2024 09:30:22 +1030 Subject: [PATCH] Allow override of whole behaviourOptions, edited a comment --- packages/static-hosting/lib/static-hosting.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index cf049143..73e456bc 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -140,7 +140,7 @@ export interface StaticHostingProps { enableStaticFileRemap?: boolean; /** - * Overrides default behaviour paths with a prefix and takes in options to apply to each static file behaviour + * Overrides default behaviour paths with a prefix and takes in behviour options to apply on the prefix behaviour * * @default true */ @@ -576,12 +576,17 @@ export class StaticHosting extends Construct { props.defaultBehaviourPrefixes?.forEach(prefix => { additionalBehaviors[`${prefix.prefix}*`] = { - origin: s3Origin, - viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS, + origin: prefix.behaviourOverride.origin ?? s3Origin, + viewerProtocolPolicy: + prefix.behaviourOverride.viewerProtocolPolicy ?? + ViewerProtocolPolicy.REDIRECT_TO_HTTPS, edgeLambdas: prefix.behaviourOverride.edgeLambdas, - originRequestPolicy: originRequestPolicy, - cachePolicy: originCachePolicy, - responseHeadersPolicy: responseHeadersPolicy, + originRequestPolicy: + prefix.behaviourOverride.originRequestPolicy ?? originRequestPolicy, + cachePolicy: prefix.behaviourOverride.cachePolicy ?? originCachePolicy, + responseHeadersPolicy: + prefix.behaviourOverride.responseHeadersPolicy ?? + responseHeadersPolicy, }; });