简体   繁体   中英

Phonegap: Source URL is not in Whitelist

I am trying to get PhoneGap 2.4.0 FileTransfer working on Android 4.2.

I get a Logcat warning message saying:

The Source URL is not in white list: 'http://api.etc.com'

Inside my res/xml/cordova.xml I have

<access origin=".*" subdomains="true"/>

This is supposed to whitelist all URL's but no luck, I still get the same warning and FileTransfer error 3.

Any ideas? Can I check if cordova.xml is being parsed at all?

Edit: I'm using a CordovaWebView.

If you are not using DroidGap, you need:

Config.init(this);

In the onCreate of your activity. Otherwise, all whitelisting will fail. Just found this out after two hours of painful digging.

It should work if you change your XML to:

<access origin="*" subdomains="true"/>

This white-lists basically the entire internet. If you only want to white-list your domain, use something more specific. See details here: http://docs.phonegap.com/en/2.4.0/guide_whitelist_index.md.html

The "origin" attribute is now "uri".

I managed to fix the problem by using PhoneGap 1.9.0 instead of 2.4.0. The errors return when using later versions.

I also managed to get it working by not using CordovaWebView but by using PhoneGap build. But this isn't viable in my case.

If you are using wild card in the whitelist URL configuration, don't use subdomain property.

Looks like you have to be very specific in how you write the tags in config.xml especially when it comes to allowing subdomains - apparently specifying subdomains does not work with wildcards so you need two blocks of tags.

<access origin="*.google.com" />
<access origin="*.googleapis.com" />
<access origin="*.gstatic.com" />
<access origin="*.googleusercontent.com" />
<access origin="google.com" subdomains="true"/>
<access origin="googleapis.com" subdomains="true"/>
<access origin="gstatic.com" subdomains="true"/>
<access origin="googleusercontent.com" subdomains="true"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM