@@ -576,6 +576,8 @@ Resources:
576
576
Type : AWS::S3::Bucket
577
577
Properties :
578
578
BucketName : !Sub ${S3BucketPrefix}-ui
579
+ WebsiteConfiguration :
580
+ IndexDocument : index.html
579
581
580
582
CloudFrontOriginAccessIdentity :
581
583
Type : AWS::CloudFront::CloudFrontOriginAccessIdentity
@@ -635,6 +637,9 @@ Resources:
635
637
Cookies :
636
638
Forward : none
637
639
CachePolicyId : 658327ea-f89d-4fab-a63d-7e88639e58f6 # caching-optimized
640
+ LambdaFunctionAssociations :
641
+ - EventType : origin-request
642
+ LambdaFunctionARN : !Ref AppFrontendEdgeLambdaVersion
638
643
CacheBehaviors :
639
644
- PathPattern : " /api/v1/events*"
640
645
TargetOriginId : ApiGatewayOrigin
@@ -675,11 +680,6 @@ Resources:
675
680
- EnvCertificateArn
676
681
MinimumProtocolVersion : TLSv1.2_2021
677
682
SslSupportMethod : sni-only
678
- CustomErrorResponses :
679
- - ErrorCode : 403
680
- ResponseCode : 200
681
- ResponsePagePath : /index.html
682
- ErrorCachingMinTTL : 0
683
683
HttpVersion : http2
684
684
PriceClass : PriceClass_100
685
685
@@ -721,6 +721,34 @@ Resources:
721
721
CookiesConfig :
722
722
CookieBehavior : none
723
723
724
+ AppFrontendEdgeLambda :
725
+ Type : AWS::Lambda::Function
726
+ DependsOn :
727
+ - AppLogGroups
728
+ Properties :
729
+ FunctionName : !Sub ${ApplicationPrefix}-lambda-edge
730
+ Handler : " index.handler"
731
+ Role : !GetAtt AppSecurityRoles.Outputs.EdgeFunctionRoleArn
732
+ Runtime : nodejs22.x
733
+ Code :
734
+ ZipFile : |
735
+ 'use strict';
736
+ exports.handler = async (event) => {
737
+ const request = event.Records[0].cf.request;
738
+ const uri = request.uri;
739
+ if (!uri.startsWith('/api') && !uri.match(/\.\w+$/)) {
740
+ request.uri = "/index.html";
741
+ }
742
+ return request;
743
+ };
744
+ MemorySize : 128
745
+ Timeout : 5
746
+
747
+ AppFrontendEdgeLambdaVersion :
748
+ Type : AWS::Lambda::Version
749
+ Properties :
750
+ FunctionName : !Ref AppFrontendEdgeLambda
751
+
724
752
Outputs :
725
753
DomainName :
726
754
Description : Domain name that the UI is hosted at
0 commit comments