# XHR POST not working in iOS12 after using WKWebView

**URL:** <https://forum.ionicframework.com/t/xhr-post-not-working-in-ios12-after-using-wkwebview/191155>\
**Category:** Ionic Native\
**Created:** [June 13, 2020, 5:29am UTC](https://forum.ionicframework.com/t/xhr-post-not-working-in-ios12-after-using-wkwebview/191155 "2020-06-13T05:29:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![heyypatrick](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@heyypatrick](https://forum.ionicframework.com/u/heyypatrick)\
**Post date:** [June 13, 2020, 5:29am UTC](https://forum.ionicframework.com/t/xhr-post-not-working-in-ios12-after-using-wkwebview/191155/1 "2020-06-13T05:29:34Z")

</div>

Hi! I’m having an issue on making POST XHR request when it’s accessed from iOS 12 but works fine with Android, Chrome and \<= iOS 13. I’m already stuck on this problem for a day now and my deadline is getting nearer. I read a lot of article that this is about CORS in WKWebView but I already have my backend configured to:

```auto
allow_origin = ['*'];

```

Everytime I build the project and login it always returns me this `0 Unknown Error` error:

```auto
{"headers":{"normalizedNames":{},"lazyUpdate":null,"headers":{}},"status":0,"statusText":"Unknown Error","url":"https://test.dummy.com/api/auth_user/","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://test.dummy.com/api/auth_user/: 0 Unknown Error","error":{"isTrusted":true}}

```

Here’s my `config.xml`:

```auto
<platform name="ios">
    <feature name="CDVWKWebViewEngine">
        <param name="ios-package" value="CDVWKWebViewEngine" />
    </feature>
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
    <preference name="WKWebViewOnly" value="true" />
    ...
</platform>

```

Here’s my `package.json`:

```auto
 "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@ionic-native/core": "^5.0.7",
    "@ionic-native/http": "^5.26.0",
    "cordova-ios": "^6.0.0",
    "cordova-plugin-advanced-http": "^2.5.1",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^4.2.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    ...

```

I’m using the `HttpClient` from `@angular/common/http` to fetch my resource. I’m fetching my resources from a service like this:

```auto
loginUser(credentials) {
    return this.http.post('https://test.dummy.com/api/auth_user/', credentials);
}

```

Thank you very much! 🙂

---

<div class="post-metadata">

**Author:** ![Aymane](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Aymane](https://forum.ionicframework.com/u/Aymane)\
**Post date:** [August 17, 2020, 12:46pm UTC](https://forum.ionicframework.com/t/xhr-post-not-working-in-ios12-after-using-wkwebview/191155/2 "2020-08-17T12:46:24Z")

</div>

Hello all,  
I’m facing the same problem here. Did you @heyypatrick find any solutions for that ?

---

<div class="post-metadata">

**Author:** ![heyypatrick](https://avatars.discourse-cdn.com/v4/letter/h/8797f3/32.png) [@heyypatrick](https://forum.ionicframework.com/u/heyypatrick)\
**Post date:** [August 18, 2020, 5:36am UTC](https://forum.ionicframework.com/t/xhr-post-not-working-in-ios12-after-using-wkwebview/191155/3 "2020-08-18T05:36:47Z")

</div>

Hi @Aymane

I fixed this by using this [Ionic native library](https://ionicframework.com/docs/native/http) instead of using Angular’s `HTTPClientModule`. You have to re-write all your code for server requests. I think the issue is connected with iOS’s deprecation for applications using UIWebView. For a short-term fix, you have to set the minimum iOS version to iOS13. 🙂
