【发布时间】:2018-09-21 07:29:12
【问题描述】:
我有一个 Ionic 3 应用程序,它使用与我之前的 ionic 应用程序相同的 API。
登录时出现以下错误:
响应状态为:0 对于 URL:null
我环顾四周,每个人都在提到服务器端的 CORS 问题,但情况并非如此,因为我的 API 以前可以工作并且仍然可以在现有应用程序上工作。
这是我的登录信息:
login(credentials) {
return new Promise((resolve, reject) => {
this.http.post(this.global.base() + 'login', JSON.stringify(credentials), { headers: this.contentHeader })
.subscribe(res => {
resolve(res.json());
}, (err) => {
reject(err);
});
});
}
我的配置 xml(为了说明而修剪):
<content src="index.html" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<plugin name="cordova-plugin-device" spec="^1.1.4" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
<plugin name="cordova-sms-plugin" spec="^0.1.11" />
<plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
<engine name="ios" spec="~4.4.0" />
我的 index.html:
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#4e8ef7">
<!-- add to homescreen for ios -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
我的设置:
cli packages: (/usr/local/lib/node_modules)
@ionic/cli-utils : 1.14.0
ionic (Ionic CLI) : 3.14.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.0.1
Cordova Platforms : ios 4.4.0
Ionic Framework : ionic-angular 3.7.1
System:
ios-deploy : 1.9.2
Node : v7.7.1
npm : 4.1.2
OS : macOS Sierra
Xcode : Xcode 9.0.1 Build version 9A1004
Misc:
backend : legacy
谁能指出我正确的方向?
【问题讨论】:
标签: angular ionic-framework ionic3