title: Ionic 5 angular [CORS POLICY in get methode]
body: <p>I want get data from external api but i'm blocked because of cors policy , i cannot modify header at server side.</p>
  <p>I found some solutions but not work for me,one of them is use chrome extension but when i run the application in my device i got the same error</p>
  <p>Error Msg:</p>
  <blockquote>
  <p>Access to XMLHttpRequest at 'URL' from origin 'http://localhost:8100'
  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.</p>
  </blockquote>
  <p>This is my code:</p>
  <pre><code>const url = 'http://host.com:port_number/get.php';
  let headers=new HttpHeaders({
    'Access-Control-Allow-Headers': 'Accept,X-Custom-Header',
    'Access-Control-Allow-Origin':'*',
    'Access-Control-Allow-Credentials':'true'
  });
  return this.http.get(url, {headers:headers, params: new HttpParams().set('username', this.log).set('password', this.pass), responseType: 'text' ,observe: 'response'}).subscribe(
    data =&gt; {
      
      console.log(data);
    },
    error =&gt; console.error(error),
    () =&gt; {
    });
  </code></pre>