CORS generally occurs due to one of the following reason:
- Hitting the Server from a localhost file(like localhost:4200/index.html)
- Hitting an External API which is not hosted on your server i.e. (
api.fontawesome.com/login)
- Hitting an Internal API from your App.
- Hitting an API which is on https from an http origin.
To solve the CORS issue you can use the CORS header called Access-COntrol-Allow-Origin and set it to * to allow it from any origin like this:
Access-Control-Allow-Origin: *
This way it will allow it to access any URL from any Origin.
Refer to below article for more info:
https://daveceddia.com/access-control-allow-origin-cors-errors-in-angular/