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
gefragt vor einem Jahr622 Aufrufe
1 Antwort
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
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen