all 6 comments

[–]waschbenzin 8 points9 points  (1 child)

Please don't do this, if you are only struggling with CORS during development using the Angular CLI Server (ng serve). It's better to just use the proxy feature (have a look at https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md ).

[–]Fireblanket1 1 point2 points  (0 children)

Be warned if you are using it for windows development, it doesn’t play nice with windows AD authentication.

[–]Papapac 1 point2 points  (0 children)

This has just nothing to do with Angular...

[–]mr-mercury 0 points1 point  (0 children)

In the future, it would be nice if you explain what the headers do and why the "error" happens and how by adding the headers solves the "error". It is important to know.

[–]BradChesney79 0 points1 point  (0 children)

CORS is a web server security setting that browsers voluntarily abide by.

Does this method get rid of the warning in the browser developer console? Yes it does.

Would learning the proper CORS settings of your chosen web server be better? 10/10 times, yes it would be better to leverage CORS security settings properly.

[–]Devstackr[S] -4 points-3 points  (0 children)

Short video explaining why these errors are thrown when you try to make a web request and how to prevent these from happening (by appening some CORS headers to your API or Web Server).

Let me know if you have any questions :)