title: CORS config on angular 7
body: <p>Hello I have been struggling with getting the <code>CORS</code> to work. I saw <a href="https://stackoverflow.com/questions/53473754/angular-7-app-getting-cors-error-from-angular-client">this post</a> which I think got me closer, however, I have followed the link in that post to <a href="https://angular.io/guide/build#using-corporate-proxy" rel="nofollow noreferrer">angular.io</a> and used that.</p>
  
  <p>So let me explain my problem, I am createing the proxy:</p>
  
  <pre><code>var HttpsProxyAgent = require('https-proxy-agent');
  var proxyConfig = [{
    context: '/api',
    target: 'http://localhost:3000',
    secure: false
  }];
  
  function setupForCorporateProxy(proxyConfig) {
    var proxyServer = process.env.http_proxy || process.env.HTTP_PROXY;
    if (proxyServer) {
      var agent = new HttpsProxyAgent(proxyServer);
      console.log('Using corporate proxy server: ' + proxyServer);
      proxyConfig.forEach(function(entry) {
        entry.agent = agent;
      });
    }
    return proxyConfig;
  }
  
  module.exports = setupForCorporateProxy(proxyConfig);
  </code></pre>
  
  <p>and I am calling <code>npm start</code> with the script looking like: <code>"start": "ng serve --proxy-config proxy.js"</code>but I'm trying to do a post that looks like:</p>
  
  <pre><code>let url:string='/api/Acounts/Login';
  
  this.http.post(url, body).subscribe(x=&gt; x.doStuff);
  </code></pre>
  
  <p>I would expect it to call <code>http://localhost:3000/Accounts/Login</code> but it is actually calling <code>http://localhost:42000/api/Accounts/Login</code></p>
  
  <p>So my question is why is it calling the incorrect address, and how can i make it call the correct address?</p>
  
  <p><strong>EDIT:</strong>
  I wanted to add <code>protractor.conf.js</code> too.</p>
  
  <pre><code>const { SpecReporter } = require('jasmine-spec-reporter');
  
  exports.config = {
    allScriptsTimeout: 11000,
    specs: [
      './e2e/**/*.e2e-spec.ts'
    ],
    capabilities: {
      'browserName': 'chrome'
    },
    directConnect: true,
    baseUrl: 'http://localhost:4200/',
    framework: 'jasmine',
    jasmineNodeOpts: {
      showColors: true,
      defaultTimeoutInterval: 30000,
      print: function() {}
    },
    onPrepare() {
      require('ts-node').register({
        project: 'e2e/tsconfig.e2e.json'
      });
      jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
    }
  };
  </code></pre>