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.

What do you mean by CORS?

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.

How does CORS manage requests from an external domain?

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

Why do we get CORS issue or rather say why does CORS issue occurs?

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

Do You Know How to Resolve CORS Issues in Angular ?
1.45 GEEK