最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - whitelisting a domain in ionic app - Stack Overflow

programmeradmin9浏览0评论

I am going through the ionic tutorial present in

.html

and ran the app on browser

ionic serve

and in android using

ionic emulate android 

When I run the app as instructed in tutorial, it works well on my chrome browser but when I try to run on emulator, I dont see any data, its just empty screens with menus. I suspect its the problem with whilelist and added

  <allow-navigation href="*" />

to my /config.xml file but it still doesn't work, My current config.xml file is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id=".ionicframework.conference472350" version="0.0.1" xmlns="" xmlns:cdv=".0">
  <name>conference</name>
  <description>
        An Ionic Framework and Cordova project.
    </description>
  <author email="hi@ionicframework" href="/">
      Ionic Framework Team
    </author>
  <content src="index.html"/>
  <access origin="*" />
  <allow-intent href="*" />
  <allow-navigation href="*" />
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>
  </feature>
  <platform name="android">
    <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
  </platform>
</widget>

I am debugging the app in chrome devtools and this is the error I get in console for the app

Failed to load resource: net::ERR_CONNECTION_REFUSED

I am going through the ionic tutorial present in

http://ccoenraets.github.io/ionic-tutorial/build-ionic-project.html

and ran the app on browser

ionic serve

and in android using

ionic emulate android 

When I run the app as instructed in tutorial, it works well on my chrome browser but when I try to run on emulator, I dont see any data, its just empty screens with menus. I suspect its the problem with whilelist and added

  <allow-navigation href="*" />

to my /config.xml file but it still doesn't work, My current config.xml file is

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id=".ionicframework.conference472350" version="0.0.1" xmlns="http://www.w3/ns/widgets" xmlns:cdv="http://cordova.apache/ns/1.0">
  <name>conference</name>
  <description>
        An Ionic Framework and Cordova project.
    </description>
  <author email="hi@ionicframework" href="http://ionicframework./">
      Ionic Framework Team
    </author>
  <content src="index.html"/>
  <access origin="*" />
  <allow-intent href="*" />
  <allow-navigation href="*" />
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="android-minSdkVersion" value="16"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="3000"/>
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>
  </feature>
  <platform name="android">
    <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
  </platform>
</widget>

I am debugging the app in chrome devtools and this is the error I get in console for the app

Failed to load resource: net::ERR_CONNECTION_REFUSED

Share Improve this question edited Jun 9, 2015 at 10:50 raju asked Jun 9, 2015 at 7:47 rajuraju 5,00817 gold badges66 silver badges121 bronze badges 2
  • Have you added the meta tag to your index.html file? If not, then add this line of code: <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> – Keval Commented Jun 9, 2015 at 10:23
  • I added this meta tag but I still have 1 error of ERR_CONNECTION_REFUSED – raju Commented Jun 9, 2015 at 10:50
Add a ment  | 

1 Answer 1

Reset to default 5

Interestingly enough, I had the same issue while developing my app.

Have you installed the plugin correctly? You didn't mention if you did.

You need to install the cordova whitelist plugin first. I did this via npm.

I also added all access to resources in my config.xml:

  <access origin="*" />
  <allow-intent href="*" />
  <allow-navigation href="*" />

Though, that is not remended. Rather, allow access to the resources you need for the app.

发布评论

评论列表(0)

  1. 暂无评论