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
asked 10 months ago596 views
1 Answer
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
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions