# Ionic proxy api

**URL:** <https://forum.ionicframework.com/t/ionic-proxy-api/135926>\
**Category:** ionic-v3\
**Created:** [July 23, 2018, 8:20am UTC](https://forum.ionicframework.com/t/ionic-proxy-api/135926 "2018-07-23T08:20:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbuscano003](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@paulbuscano003](https://forum.ionicframework.com/u/paulbuscano003)\
**Post date:** [July 23, 2018, 8:20am UTC](https://forum.ionicframework.com/t/ionic-proxy-api/135926/1 "2018-07-23T08:20:01Z")

</div>

how to implement api proxy in ionic? My console.log says

“Failed to load [https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1:](https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1:) No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘[http://localhost:8100](http://localhost:8100)’ is therefore not allowed access.”

Someone said I’m gonna use proxy api.

my actual api:

```auto
https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1

```

my ionic.config.json

```auto
{
  "name": "slingers",
  "app_id": "",
  "type": "ionic-angular",
  "integrations": {
    "cordova": {}
  },
  "proxies": [
    {
      "path": "/api",
      "proxyUrl": "https://api.wh.geniussports.com"
    }
  ]
}

```

my home.ts

```auto
  getMatches(){
  
    this.http.get(this.lets + '/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1')
    .map(res => res.json())
    .subscribe(data => {
      this.dataMatches = data.response.data;
      console.log(this.dataMatches);
    }, err => {
      console.log(err);
    });
  }

```

in my ios device console says:

```auto
http://localhost:8080/api/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782&fromDate=2017-11-17&toDate=2017-12-17&teamId=88261&limit=1
Failed to load resource: the server responded with a status of 404 (Not Found)

```

---

<div class="post-metadata">

**Author:** ![nirman99](https://avatars.discourse-cdn.com/v4/letter/n/f19dbf/32.png) [@nirman99](https://forum.ionicframework.com/u/nirman99)\
**Post date:** [July 26, 2018, 2:05am UTC](https://forum.ionicframework.com/t/ionic-proxy-api/135926/2 "2018-07-26T02:05:52Z")

</div>

Best way is to fix CORS in your server. Because you have to fix it anyways to make http calls on iOS devices. That is because WebKitWebView enforces CORS.

Allow the origin [http://localhost:8100](http://localhost:8100)  
and allow the http methods

If you cannot change the server, then use Cordova http plugin.

---

<div class="post-metadata">

**Author:** ![paulbuscano003](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@paulbuscano003](https://forum.ionicframework.com/u/paulbuscano003)\
**Post date:** [July 26, 2018, 5:03am UTC](https://forum.ionicframework.com/t/ionic-proxy-api/135926/3 "2018-07-26T05:03:52Z")

</div>

I fixed the issue using UIWeb instead of WKWeb. and using platform [https://ionicframework.com/docs/api/platform/Platform/](https://ionicframework.com/docs/api/platform/Platform/)

```auto
   if (this.platform.is('mobile')) {
      this.lets = "https://api.wh.geniussports.com/v1";
    } else {
      this.lets = "/v1";
    }

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:28pm UTC](https://forum.ionicframework.com/t/ionic-proxy-api/135926/4 "2021-07-19T21:28:58Z")

</div>

Closed on July 19, 2021, 9:28pm UTC


