Skip to main content

Posts

Showing posts from September, 2022

AWS API Gateway - Handling CORS errors

  AWS API Gateway Console provides a simple mechanism to enable CORS and handle Cross-Origin browser requests to REST Apis/ Services. You may select any "resource" in the API Management console and select "Enable CORS" from the "Actions" Dropdown.   You may expect this feature would be simple click and forget solution but you might still encounter CORS issues when you make API request calls from your favourite UI frameworks such as React, Angular, Vue and even plain vanilla javascript. You may end up tinkering your backend service irrespective of the technology used; Lambda (AWS), Springboot (Java), Flask, Express (nodejs) ...never ending list of REST API platforms. Either you end up lucky solving the issue or left searching for answers. You might encounter errors such as - Origin http://[yourdomain].com is not allowed by Access-Control-Allow-Origin.  Origin http://localhost:4200 is not allowed by Access-Control-Allow-Origin.  Reason: CORS header 'Acce