Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions infrastructure/modules/cloudfront/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ resource "aws_cloudfront_distribution" "this" {
ssl_support_method = var.acm_certificate_arn != null ? var.ssl_support_method : null
minimum_protocol_version = var.acm_certificate_arn != null ? var.minimum_protocol_version : null
}
dynamic "custom_error_response" {
for_each = var.distribution_type == "s3" ? [1] : []
content {
error_code = 403
Copy link
Preview

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider also handling 404 errors by adding a second custom_error_response block mapping 404 to 200, which is a common practice for SPAs to catch missing routes.

Copilot uses AI. Check for mistakes.

response_code = 200
response_page_path = "/"
Copy link
Preview

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The response_page_path should point to your SPA entry file (e.g., /index.html) instead of just / to ensure CloudFront serves the correct object.

Suggested change
response_page_path = "/"
response_page_path = "/index.html"

Copilot uses AI. Check for mistakes.

}
}

tags = var.tags
}
Loading