Skip to content

Commit

Permalink
fix: Add redirect to https viewer protocol policy (#1378)
Browse files Browse the repository at this point in the history
Fixes #1351 by making use of the [viewer protocol
policy](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-defaultcachebehavior.html#cfn-cloudfront-distribution-defaultcachebehavior-viewerprotocolpolicy)
of Cloudfront distributions.

* Enforces https redirects for clients that do not support HSTS header
* Applied to all behaviors of Cloudfront distribution

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
  • Loading branch information
truggeriaws authored Feb 1, 2024
1 parent 1cc2245 commit 3c02595
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
70 changes: 35 additions & 35 deletions src/__tests__/__snapshots__/construct-hub.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/__tests__/devapp/__snapshots__/snapshot.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/webapp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class WebApp extends Construct {
eventType: cloudfront.FunctionEventType.VIEWER_RESPONSE,
},
],
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
};

const websiteOrigin = new origins.S3Origin(this.bucket);
Expand Down

0 comments on commit 3c02595

Please sign in to comment.