0
我一直在遇到這個問題,因爲我試圖在設備上運行我的應用程序。 我重新安裝了cordova-whitelist插件。離子應用REST API調用指向一個錯誤的URL
當我嘗試使用ionic serve
命令再次從瀏覽器運行應用程序。 該應用程序調用錯誤的API ..
下面是當我嘗試登錄到應用程序時在我的控制檯中的日誌。
POST http://192.168.43.57:8100/auth/login 404 (Not Found)
我的JS代碼宣佈$http
網址是從什麼控制檯指向不同。
登錄控制器
$scope.login = function() {
var credentials = {
username: $scope.loginData.username,
password: $scope.loginData.password
}
$auth.login(credentials).then(function() {
$http.get('http://api.mydomain.com/api/login')
.success(function(response){
var user = JSON.stringify(response.user);
localStorage.setItem('user', user);
$rootScope.currentUser = response.user;
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('tabs.download');
})
.error(function(){
var alertPopUp = $ionicPopup.alert({
title: 'Login Failed!',
template: 'Invalid credentials'
});
})
});
}
UPDATE:
config.xml中
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.ticappnew343084" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Test Mobile</name>
<description>
TIC Inspection Report Generator
</description>
<author email="[email protected]" href="http://example.com/">
Author Name
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="SplashScreenDelay" value="2000"/>
<preference name="FadeSplashScreenDuration" value="2000"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar"/>
</feature>
<plugin name="ionic-plugin-keyboard" spec="~2.2.1"/>
<allow-navigation href="http://192.168.43.57:8100"/>
</widget>
請讓我看看你的config.xml –