title: Angular:Post request becomes options
body: <p>I'm using angular 6, httpClient, trying to login, no token required, just a username and a password, can't modify the server.</p>
  
  <p><code>login.ts</code></p>
  
  <pre><code>  onLogin() {
      this.authService.login(this.email, this.password).subscribe(data =&gt; {
        console.log(data);
      });
    }
  </code></pre>
  
  <p><code>auth service</code></p>
  
  <pre><code>  login(username, password) {
      const data = {
        username: username,
        password: password
      };
  
      const headers = new HttpHeaders();
      headers.set('Content-Type', 'application/json');
      return this.http.post(this.login_url, data, { headers: headers });
    }
  </code></pre>
  
  <p>There are plenty of questions like <a href="https://stackoverflow.com/questions/47180634/i-get-http-failure-response-for-unknown-url-0-unknown-error-instead-of-actu">this one</a> but those were for angularjs and I'm using angular 6, some answers gave articles to read with no practical coding answer, and some says to change the header, but as far as I can tell from my postman tests, the server only accepts <code>'Content-Type', 'application/json'</code> And it's working perfectly on postman. When I do it in angular, my post request, becomes options.</p>
  
  <p>Some even say that to avoid CORS, you should setup an interceptor, but that's for when you have a token, no? you save it in localStorage and then you use it, I don't have a token. The server <code>X-Session</code> in the header.</p>
  
  <p>Some say, to create a proxy, <code>package.json</code>,</p>
  
  <pre><code>`"start": "ng serve --proxy-config proxyconfig.json",`
  </code></pre>
  
  <p><code>proxyconfig.json</code></p>
  
  <pre><code>{
      "/api": {
          "target": "example.com",
          "secure": false,
          "changeOrigin": true
      }
  }
  </code></pre>
  
  <p>And the <code>login_url</code> in <code>auth service</code> would point to the rest endpoint without <code>/example/api</code>. I also tried that, it's not working either.</p>
  
  <p>Some says, you have to edit the webserver, to add <code>Access-Control-Allow-Origin</code>, I'd like not to do that, if possible. If not, I'll contact my company and ask them to do it. I'd like a solution using angular 6.</p>