From 7bdcf33771e0c243a6955a104658a463de644c3c Mon Sep 17 00:00:00 2001 From: tyler Date: Tue, 12 Dec 2023 01:18:02 +0000 Subject: [PATCH] Support SPA requests by routing 404 to /index.html --- terraform/web.tf | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/terraform/web.tf b/terraform/web.tf index a2be36ab..4233027f 100644 --- a/terraform/web.tf +++ b/terraform/web.tf @@ -227,13 +227,8 @@ module "cdn" { custom_error_response = [ { error_code = 404 - response_code = 404 - response_page_path = "/errors/404.html" - }, - { - error_code = 403 - response_code = 403 - response_page_path = "/errors/403.html" + response_code = 200 + response_page_path = "/index.html" }, ] @@ -264,6 +259,9 @@ module "cdn" { compress = true cache_policy_id = data.aws_cloudfront_cache_policy.Managed-CachingOptimized.id use_forwarded_values = false + + // See https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/url-rewrite-single-page-apps + function_association = {} } ordered_cache_behavior = [