Skip to content
This repository has been archived by the owner on Sep 14, 2022. It is now read-only.

Commit

Permalink
Add prependCustomOriginBehaviours option
Browse files Browse the repository at this point in the history
  • Loading branch information
John Smith committed Oct 12, 2021
1 parent cad68f1 commit 8692266
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export interface StaticHostingProps {
* Used to add Custom origins and behaviors
*/
customOriginConfigs?: Array<SourceConfiguration>;
/**
* Used to prepend the behaviours introduced as part of customOriginConfigs.
* This is a work around until this construct is updated to use the new
* Distribution API.
* https://docs.aws.amazon.com/cdk/api/latest/docs/aws-cloudfront-readme.html#distribution-api
*/
prependCustomOriginBehaviours?: boolean;

/**
* Optional set of behaviors to override the default behvior defined in this construct
Expand Down Expand Up @@ -123,7 +130,11 @@ export class StaticHosting extends Construct {

// Add any custom origins passed to the construct
if (props.customOriginConfigs) {
originConfigs = originConfigs.concat(props.customOriginConfigs);
if (props.prependCustomOriginBehaviours) {
originConfigs = props.customOriginConfigs.concat(originConfigs);
} else {
originConfigs = originConfigs.concat(props.customOriginConfigs);
}
}


Expand Down

0 comments on commit 8692266

Please sign in to comment.