This question already has an answer here:
- How to create cross-domain request? 7 answers
In angular2 how to use CORS cross domain, it is necessary to set the response header at the server, how to set?
This question already has an answer here:
In angular2 how to use CORS cross domain, it is necessary to set the response header at the server, how to set?
You need to set the cross domain origin in only server side not in client side. So enable CORS in server side.
And if you are using Web Api for a server call . Enable CORS and Access-Control-Allow-Origin.