supplier_central_frontend/patch.diff
vickytechkey 420df528a6
All checks were successful
Beta CI/CD Pipeline / build-and-test (push) Successful in 58s
Beta CI/CD Pipeline / deploy-beta (push) Successful in 12s
configure API proxy to EC2 origin in CDK stack and remove hardcoded backend URL from config
2026-09-05 15:39:52 +05:30

30 lines
1.5 KiB
Diff

--- /home/vignesh/github/Tiproemail/aws_cdk/lib/betasupplier-site-stack.ts
+++ /home/vignesh/github/Tiproemail/aws_cdk/lib/betasupplier-site-stack.ts
@@ -19,13 +19,25 @@
+ const ec2Origin = new origins.HttpOrigin('ec2-16-113-57-127.ap-south-2.compute.amazonaws.com', {
+ protocolPolicy: cloudfront.OriginProtocolPolicy.HTTPS_ONLY,
+ });
+
// 2. Create CloudFront Distribution
// origins.S3Origin will automatically create an Origin Access Identity (OAI)
// and update the S3 bucket policy to allow access only from this CloudFront distribution.
const distribution = new cloudfront.Distribution(this, 'BetaSupplierSiteDistribution', {
defaultRootObject: 'index.html',
defaultBehavior: {
origin: new origins.S3Origin(websiteBucket),
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD,
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD,
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
},
+ additionalBehaviors: {
+ '/api/*': {
+ origin: ec2Origin,
+ viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
+ allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
+ cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
+ originRequestPolicy: cloudfront.OriginRequestPolicy.ALL_VIEWER,
+ }
+ },
errorResponses: [