Search code examples
typescriptionic-frameworkionic4

Error: CORS policy: No 'Access-Control-Allow-Origin' header is present in ionic 4


Access to XMLHttpRequest at 'myURL' from origin 'localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Source code

this.http.get(login_url ).subscribe(data => {
      this.responseArray = data;
      console.log(this.responseArray.SINGLE_HOTEL_APP[0].success);
    });

I am using ionic HTTP plugin


Solution

  • Either you put in your web api header ('Allow-Access-Origin:') or send it with the request from ionic as options that take new HttpHeaders().set('Allow-Access-Origin:'); And thats all.Any more details i'm ready.