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