-->

04-28 16:06:29.756: W/SystemWebViewClient(16778):

2019-09-06 02:06发布

问题:

This problem appeared when I update the ionic and cordova, $http can't normally work any more, always return null. in debug line apeared "04-28 16:06:29.756: W/SystemWebViewClient(16778): URL blocked by whitelist:"

回答1:

This error happened after cordova update 5.0.0.

Like Santosh said, you just need add the plugin https://github.com/apache/cordova-plugin-whitelist.git to your app and everything will work. I was getting the same error and i fixed with this plugin.

You will need add the follow code to your webconfig file:

<allow-navigation href="http://yourDomain.com/*" />


回答2:

With the updated version of cordova-android, you now need to include the cordova-whitelist-plugin.

https://github.com/apache/cordova-mobile-spec/tree/master/cordova-plugin-whitelist

Try adding that to your project

For example -

      cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git

For more help read issue on https://github.com/driftyco/ionic/issues/3597



回答3:

Use this command with new CLI:

ionic cordova plugin add cordova-plugin-whitelist

And in the config.xml no need to change the default settings which are:

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />

Here * represents anything so I solved my CORS problem using these settings.

Note:Don't forget to remove the platform after adding the plugin although it's added automatically there too but it's better to take precaution as you'll never know what might be the cause using

ionic cordova plugin save
ionic cordova platform remove android
ionic cordova platform remove ios

Then add again

ionic cordova platform add android
ionic cordova platform add ios