Hi all, today I am sharing my experience on CORS issues and how to handle them in a client-side angular app. Before starting this topic I will give you all a brief knowledge about CORS and how CORS is used for managing external resources.
CORS stands for Cross-Origin Resource Sharing. It is a mechanism that is used to bypass the same-origin policy so that resources from one origin can access resources from another origin in a secure manner.
CORS manages request from the external domain by using a set of newly created HTTP headers which are as follows -
Access-Control-Allow-Origin
Access-Control-Allow-Credentials
Access-Control-Allow-Headers
Access-Control-Allow-Methods
Access-Control-Expose-Headers
Access-Control-Max-Age
Access-Control-Request-Headers
Access-Control-Request-Method
Origin
CORS issue occurs in web application if your backend server (your service) is running on a different domain and it is not configured properly.
Note: Even if your backend server is running on a localhost with a different port it is treated as a different domain.
So CORS issues may occur while developing an angular application.
#angular #angular2