Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS v12 Https requests errors

I noticed that https requests made from my Ionic Angular app on iOS v12 are failing respectively never reach my backend.

I could confirm that my app is productive and the fact that this error only occurs on iOS >= v12

When I debug in Xcode 10 beta I get the following error

{“headers”:{“normalizedNames”:{},“lazyUpdate”:null,“headers”:{}},“status”:0,“statusText”:“Unknown Error”,“url”:null,“ok”:false,“name”:“HttpErrorResponse”,“message”:“Http failure response for (unknown url): 0 Unknown Error”,“error”:{“isTrusted”:true}}

My Node / Express.js backend set the following headers

var allowedOrigins = ["https://example.com", "http://ionic.local", "http://localhost:8080"];

 var origin = req.headers.origin;
 if(allowedOrigins.indexOf(origin) > -1){
        res.setHeader('Access-Control-Allow-Origin', origin);
 } else {
        res.setHeader("Access-Control-Allow-Origin", "https://example.com");
    }

 res.header("Access-Control-Allow-Credentials", "true") 
 res.header("Access-Control-Allow-Headers", "Origin, Authorization, Content-Type, Content-Range, Content-Disposition, Content-Description, X-Requested-With, X-ACCESS_TOKEN");
 res.header("Access-Control-Allow-Methods", "GET,PUT,POST");

Anyone is facing the same problem? What did you change in your code to fix the problem for iOS v12?

P.S.: I have opened an issue by Apple

Also here the linked subject on the Ionic forum: https://forum.ionicframework.com/t/ios-12-beta-preflight-requests-fail

And just in case opened an issue on the WkWebView plugin: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/112

UPDATE

I'm not sure but it looks like that I only face issue while querying POST requests respectively that I don't face it while doing GET requests...could you confirm that too?

UPDATE 2

In the following discussion/issue, https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/112, we are also betting on a bug in the iOS version itself. Let see if it will be corrected with the next beta version

UPDATE 3

Xcode 10 beta 2 respectively iOS 12 beta 2 released Tuesday 19th June 2018 solved my problem

like image 291
David Dal Busco Avatar asked Jun 05 '18 18:06

David Dal Busco


2 Answers

The problem was an internal problem of iOS 12 beta 1

Xcode 10 beta 2 respectively iOS 12 beta 2 released Tuesday 19th June 2018 solved my problem

like image 190
David Dal Busco Avatar answered Nov 13 '22 13:11

David Dal Busco


I'm feeling very confident that this is just a beta 1 bug with no confirmed work around. I never found an opportunity to get this verified in person while at WWDC, but it seems to be very confirmed by multiple sources including this bug on open radar. I'm going to file an additional bug with Apple directly and will update my answer with any responses.

Update: I've tested multiple devices on iOS 12 beta 2 and the issue seems to be resolved. No update on the bug filed with Apple, but I'm going to assume that it was addressed in the latest update.

Update 2: Apple has finally closed my bug as fixed.

like image 38
InkGolem Avatar answered Nov 13 '22 13:11

InkGolem