title: net::ERR_INVALID_HTTP_RESPONSE error after post request with Angular 7
body: <p>I am working on small web application and I am using angular 7 and asp.net core web api as a back end. I am trying to make http post request with angular. My service returns string (token) and when I receive it, I want to show it in alert box.</p>
  
  <p>I have tested my service with <code>Postman</code> and everything works as expected.</p>
  
  <p>From the browser my request is successfully mapped to the controller's action method. I have set breakpoint in this method body and it successfully returns token without any problem.</p>
  
  <p>But httpclient returns error:</p>
  
  <p><code>[object Object]</code></p>
  
  <p>And in the browser console I see this:</p>
  
  <p><code>POST https://localhost:44385/api/auth net::ERR_INVALID_HTTP_RESPONSE</code></p>
  
  <p>I have two methods (for <code>POST</code> and for <code>GET)</code> in a service class injected into component. They look like these:</p>
  
  <pre><code>logIn(username: string, password: string) {
  
      const encodedCredentials = btoa(username + ':' + password);
  
      const httpOptions = {
          headers: new HttpHeaders({
              "Authorization": "Basic " + encodedCredentials,
              "Access-Control-Allow-Origin":"*"
          }),
          responseType: 'text' as 'text'
      };
  
      this.http.post(this.urlBase + 'auth', null , httpOptions)
      .subscribe(result =&gt; {
          alert(result);
      }, error =&gt; {
          alert(error); // [object Object]
      });
  }
  
  get(){
      return this.http.get(this.urlBase + 'auth', {responseType: 'text'});
  }
  </code></pre>
  
  <p>What can be problem?</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
  error: ProgressEvent
  bubbles: false
  cancelBubble: false
  cancelable: false
  composed: false
  currentTarget: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://localhost:44385/api/auth", __zone_symbol__loadfalse: null, __zone_symbol__errorfalse: null, __zone_symbol__xhrListener: ƒ, …}
  defaultPrevented: false
  eventPhase: 0
  isTrusted: true
  lengthComputable: false
  loaded: 0
  path: []
  returnValue: true
  srcElement: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://localhost:44385/api/auth", __zone_symbol__loadfalse: null, __zone_symbol__errorfalse: null, __zone_symbol__xhrListener: ƒ, …}
  target: XMLHttpRequest {__zone_symbol__xhrSync: false, __zone_symbol__xhrURL: "https://localhost:44385/api/auth", __zone_symbol__loadfalse: null, __zone_symbol__errorfalse: null, __zone_symbol__xhrListener: ƒ, …}
  timeStamp: 80234.59999999614
  total: 0
  type: "error"
  __proto__: ProgressEvent
  headers: HttpHeaders
  headers: Map(0) {}
  lazyUpdate: null
  normalizedNames: Map(0) {}
  __proto__: Object
  message: "Http failure response for (unknown url): 0 Unknown Error"
  name: "HttpErrorResponse"
  ok: false
  status: 0
  statusText: "Unknown Error"
  url: null
  __proto__: HttpResponseBase
  </code></pre>
  
  <p><strong>Update 2:</strong></p>
  
  <p>Request with Postman:</p>
  
  <p><a href="https://i.stack.imgur.com/SqXTX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SqXTX.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p><a href="https://i.stack.imgur.com/WrHFz.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/WrHFz.gif" alt="enter image description here"></a></p>
  
  <p><strong>Update 3:</strong> trying to get token several times showed that sometimes post request is successfull and sometimes not...</p>
  
  <p><a href="https://i.stack.imgur.com/vGPvw.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/vGPvw.gif" alt="enter image description here"></a></p>