title: ionic post request blocked by cors while postman works fine Ionic 4
body: <p>I am using ionic 4 with angular 7 . Have a post request that keeps triggering the following error, but when I test this post request in Postman it works fine:</p>
  
  <p><em>Access to XMLHttpRequest at '<a href="https://examplecode/backend/" rel="nofollow noreferrer">https://examplecode/backend/</a>' from origin '<a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.</em></p>
  
  <p>my post request: </p>
  
  <pre><code>import { HttpClient, HttpHeaders } from '@angular/common/http';
  ...
    sendCodeToServer(data) {
      this.http.post(endpoindURL, data, {
        headers: new HttpHeaders({
          'Content-Type': 'application/json'
        })
      }).toPromise().then(
        (data) =&gt; {
          console.log(data);
        }).catch((err) =&gt; {
          console.log(err);
        });
  </code></pre>
  
  <p>all I am sending is this { "id" : 1111111 }.
  As I said it works fine on Postman, but in my app I keep getting the error. The server already has several measures so this wouldn't happen</p>
  
  <pre><code>if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
        header("Access-Control-Allow-Methods: POST");         
  
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
        header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
  }
  
  header('Access-Control-Allow-Origin: *');
  header("Access-Control-Allow-Headers: *");
  </code></pre>
  
  <p>Not sure how to fix it, the servers seems fine and the request seems fine, and works in postman as well, just never works on the mobile app.</p>