Skip to content

Commit

Permalink
Allow override of whole behaviourOptions, edited a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
finnholland committed Oct 24, 2024
1 parent 0d7f5d8 commit faa19f8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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,
};
});

Expand Down

0 comments on commit faa19f8

Please sign in to comment.