CloudFront assets throwing CORS error

0

Hi, I have configured my CloudFront distribution (S3 bucket) to use a custom response header policy: like below Access-Control-Allow-Origin: [https://mydomain.com, http://localhost:8080] to be allowed.

Because of this when I access the site through load balancer url to check whether the site is up, I am getting the error that the asset has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. It works fine through the mydomain.com I am using AWS CDK to maintain the stack.

How can I remove the Cors error while accessing through load balancer url?

Thanks

Maya
已提問 1 年前檢視次數 622 次
1 個回答
0

ALB doesn't natively support CORS. CORS headers need to be added by the backend application. ALB just forwards CORS requests to the back-end application as well as forwards CORS responses to the clients.

If you have a single page application with only static content than ALB is not required.

if there is an backend application deployed in an EC2 instance with application load balancer in front than you need to CORS headers needs to be added by the backend application.

AWS
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南