'https://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

Viewed 647

I am working on AWS Cognito to authenticate APIs and using Amazon Cognito Identity JS with amplify. I added authorizer in API Gateway and it gives me error of cors when i login with cognito users but without authorizer it workes fine.

here is the error.

enter image description here

3 Answers

One simple way to analyze this issue it to use the "Launch Hosted UI" facility in AWS Cognito. This can be accessed through this path: AWS Cognito > Manage User Pools > Select User Pool > App Client Settings > Launch Hosted UI.

The URL parameters in the launched UI should be exactly same as the one setup in the application UI configured. Any deviation in any of the parameters would lead to a CORS error.

Added a chrome extension named Moesif CORS to temporarily solve this problem. Didn't find a proper solution yet.

You should set CORS details on your API services with "Enable CORS" and add your authorization header name here.

Related