From 29fefcaf2b3ce5a21f3ae944897584fd798d8996 Mon Sep 17 00:00:00 2001 From: FahdShalhoub Date: Sun, 16 Aug 2026 20:17:41 +0300 Subject: [PATCH] FIX: Added Correct CORS rules For Raw Uploaded Videos Bucket --- infrastructure/main.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/infrastructure/main.go b/infrastructure/main.go index 2fb5fe4..f888a22 100644 --- a/infrastructure/main.go +++ b/infrastructure/main.go @@ -766,6 +766,26 @@ func main() { return err } + // The browser PUTs directly to raw-uploads-bucket using the presigned + // URL from PresignVideoUpload, so the bucket (not the cms app) is + // what needs to answer the CORS preflight — scoped to the cms + // origin the upload page is actually served from. + _, err = s3.NewBucketCorsConfigurationV2(ctx, "raw-uploads-bucket-cors", &s3.BucketCorsConfigurationV2Args{ + Bucket: rawUploadsBucket.ID(), + CorsRules: s3.BucketCorsConfigurationV2CorsRuleArray{ + &s3.BucketCorsConfigurationV2CorsRuleArgs{ + AllowedMethods: pulumi.ToStringArray([]string{"PUT"}), + AllowedOrigins: pulumi.StringArray{pulumi.Sprintf("http://%s", cmsAlb.DnsName)}, + AllowedHeaders: pulumi.ToStringArray([]string{"*"}), + ExposeHeaders: pulumi.ToStringArray([]string{"ETag"}), + MaxAgeSeconds: pulumi.Int(3000), + }, + }, + }) + if err != nil { + return err + } + discoveryRepo, discoveryService, discoveryAlb, err := deployFargateService(ctx, "discovery", 8080, cluster, execRole, nil, nil, vpc.Id, subnets.Ids, albSecurityGroup, serviceSecurityGroup, db.Address, db.Port, discoveryPassword)