Facing CORS error on AWS ECS Fargate container

0

I have deployed my application backend on AWS ECS Fargate container and I deployed my application on second AWS ECS Fargate container. Both, frontend and backend, are using two different load balancers. But when I try to connect my frontend with backend it is throwing a CORS error that you can see in the following picture.

CORS ERROR

Does anyone have any idea why this error is coming and how I can resolve it?

1 個回答
1
已接受的答案

CORS (Cross Origin Resource Sharing) is a browser policy-related(Same Origin Policy) error that occurs when referring to resources from other sources (domain, port). The workaround for this is to have a proxy server, or to have the following settings in the backend application:

This is(below) just example and depends on the language/framework you use.

res.setHeader('Access-Control-Allow-Origin', "{Client Domain}");
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS, PUT, POST');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
res.header('Access-Control-Allow-Credentials', 'true');
已回答 1 年前

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

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

回答問題指南