I have tried all the possible ways found in we to solve the CORS issue in angular while runnig through VS code using ng serve

  1. Implemented the prox.conf.json and then run

ng serve --proxy config proxy.conf.json

  "/`OSTNextService`": {

    "target": "https://localhost/OSTNextService",
    "secure": true,
    "pathRewrite": {
    "^/OSTNextService": ""

"`changeOrigin": true`
  1. set the IIS header to specif domain. in my case https://localhost:4200 enter image description here

  2. setting the service global.asax file

    enter image description here

Nothing working for me and am getting error like

Access to XMLHttpRequest at 'https://localhost/OSTNextService/OSTPortalService.svc/GetUserName' from origin 'https://localhost:4200' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

when i hosted the application in IIS and mapped the dist folder to it everything working fine. but evey time i changed the .ts file i need to build the application is almost double time waste. please help by advising what i am missing here.

1 Answers

Normunds Kalnberzins On

use "/OSTNextService" instead of "/OSTNextService" in proxy file. And if you use simply "target": "https://localhost/" you do not need rewrite,

also do not use a full url in your app, but a relative /OSTNextService/OSTPortalService.svc/GetUserName, then it will hit your proxy and forward to localhost:80/...

I do not think there is any need to tinker with IIS headers.