iOS v12 Https 请求错误 [英] iOS v12 Https requests errors
问题描述
我注意到从我在 iOS v12 上的 Ionic Angular 应用程序发出的 https 请求分别失败了,它们永远不会到达我的后端.
I noticed that https requests made from my Ionic Angular app on iOS v12 are failing respectively never reach my backend.
我可以确认我的应用程序是高效的,并且这个错误只发生在 iOS >= v12
I could confirm that my app is productive and the fact that this error only occurs on iOS >= v12
当我在 Xcode 10 beta 中调试时,出现以下错误
When I debug in Xcode 10 beta I get the following error
{headers":{normalizedNames":{},lazyUpdate":null,headers":{}},status":0,statusText":未知错误",url":null,ok":false,name":HttpErrorResponse",message":Http failure response for (unknown url): 0 Unknown Error",error":{isTrusted":true}}
{"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}}
我的 Node/Express.js 后端设置以下标头
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");
有人遇到同样的问题吗?您对代码进行了哪些更改以解决 iOS v12 的问题?
Anyone is facing the same problem? What did you change in your code to fix the problem for iOS v12?
附注:我已经打开了 Apple 的问题
P.S.: I have opened an issue by Apple
还有 Ionic 论坛上的链接主题:https://forum.ionicframework.com/t/ios-12-beta-preflight-requests-fail
Also here the linked subject on the Ionic forum: https://forum.ionicframework.com/t/ios-12-beta-preflight-requests-fail
以防万一在 WkWebView 插件上打开了一个问题:https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/112
And just in case opened an issue on the WkWebView plugin: https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/112
更新
我不确定,但看起来我只在分别查询 POST 请求时遇到问题,而我在执行 GET 请求时没有遇到它......你也能确认一下吗?
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?
更新 2
在以下讨论/问题中,https://github.com/ionic-team/cordova-plugin-ionic-webview/issues/112,我们也在押注 iOS 版本本身的错误.看看下个测试版会不会修正
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
更新 3
Xcode 10 beta 2
分别于 2018 年 6 月 19 日星期二发布的 iOS 12 beta 2
解决了我的问题
Xcode 10 beta 2
respectively iOS 12 beta 2
released Tuesday 19th June 2018 solved my problem
推荐答案
问题是iOS 12 beta 1
Xcode 10 beta 2
分别于 2018 年 6 月 19 日星期二发布的 iOS 12 beta 2
解决了我的问题
Xcode 10 beta 2
respectively iOS 12 beta 2
released Tuesday 19th June 2018 solved my problem
这篇关于iOS v12 Https 请求错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!