gpt4 book ai didi

ios - CORS 问题(IONIC 3)

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:24:27 25 4
gpt4 key购买 nike

我正在尝试在 livereload 模式下处理 CORS 问题,但我无法为此找到合理的解决方案。我的后端是用 Java 开发的,它在本地主机上运行。

命令:

ionic cordova emulate ios -l -c -s --address 127.0.0.1

ion.config.json:

{
"name": "Smartmarket",
"app_id": "",
"type": "ionic-angular",
"integrations": {
"cordova": {}
},
"proxies": [{
"path": "/SmartmarketWeb/endpoint",
"proxyUrl": "http://127.0.0.1:8080/SmartmarketWeb/endpoint"
}]
}

请求示例:

let headers = new Headers({ 
'Content-Type': 'application/json'
});
let options = new RequestOptions({ headers: headers });
return this.http.post('http://127.0.0.1:8080/SmartmarketWeb/endpoint/login', json, options)
.timeout(TIMEOUT_REQUEST*1000)
.map(this.extractData)
.do(this.logResponse)
.catch(this.handleError);

错误: enter image description here

有人能帮帮我吗?我尝试了很多解决方案,但是没有一个有效。

最佳答案

Workaround only - Not a perfect solution


我在运行时遇到了同样的问题,我的带有 ASP.net 后端的 ionic 3 应用程序运行良好,它无法与 IOS(Iphone x - IoS 11 模拟器)一起​​使用。

解决方案

我更改了 web view我的 ionic 应用程序的选项。

首先,打开config.xml并添加以下属性

<feature name="CDVWKWebViewEngine">
<param name="ios-package" value="CDVWKWebViewEngine" />
</feature>
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />

然后删除所有插件和平台,然后运行或构建您的应用

详细步骤在 this url 中给出

关于ios - CORS 问题(IONIC 3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45981370/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com