53

I'm new to mobile development. I'm using Phonegap/Cordova to create a cross-platform app. My code works well on Android but when I'm porting it to iPhone it's showing an error:

[143:2003] ERROR whitelist rejection: url="abc"

Now can I overcome this problem?

Mat
  • 202,337
  • 40
  • 393
  • 406
Neji
  • 6,591
  • 5
  • 43
  • 66
  • Use cordova's white-list pugin. Worked for me on both android and IOS platforms without any other mentioned changes. https://github.com/apache/cordova-plugin-whitelist – Zeeshan Cornelius Nov 21 '16 at 13:48

7 Answers7

54

Notice: This answer only applies for PhoneGap version 1.x and below. From version 2.x onwards, whitelist configuration is done via cordova.xml.

You have to add allowed URLs into PhoneGap.plist's (or Cordova.plist) ExternalHosts array.

For example, if you want to allow access to this URL http://www.myhost.com/path/file, then add www.myhost.com as a new entry to ExternalHosts array.

If you want to allow access to content on all the subdomain of Google (e.g. maps.google.com, mails.google.com), you can add *.google.com as a new entry to ExternalHosts array.

I am not sure why you get "abc" in the link, though. Do you have "abc" as a link to anything? Is it URI fragment?

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
32

In PhoneGap 3.0, you need to edit config.xml in Project folder (note: not the www/config.xml)

<access origin="*" />
Ivan
  • 1,813
  • 16
  • 7
  • Project folder is correct, but this folder is named www if you create an app with the command line interface (which of course you don't have to do). – Uli Sep 02 '13 at 21:53
18

In PhoneGap 3.0, you need to edit www/config.xml, and add/edit <access> tags. For example, if you want to allow everything, change the tag to:

<access origin="*" />
shawkinaw
  • 3,190
  • 2
  • 27
  • 30
8

You can add this following code in Cordova.plist file:

<key>ExternalHosts</key>
       <array>
               <string>*.facebook.com</string>
       </array>

With *.facebook.com as the domain name, you can use two different sub-domains.

Xavi
  • 20,111
  • 14
  • 72
  • 63
Manish Agrawal
  • 551
  • 2
  • 6
  • 22
3

You will have to Domain Whitelist so you can access outside domains such as http://google.com.

In iOS (Cordova > 3.0.0), the whitelisting rules are found in AppName/config.xml and declared with the element <access origin="..." />

You can also use wildcards to declare domains. For example, to allow access to all subdomains and TLDs (.com, .net, etc) of Google, use *.google.*

Reference: Domain Whitelist Guide

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
wael
  • 366
  • 1
  • 2
  • 10
0

Even I got the same issue... I fixed it in the below way..In cordova.plist--> under ExternalHosts array menu, add an item as * or .. So it allows all the external links... if u have to mention one by one mention it as .facebook.,*.google.* etc.

bharath gangupalli
  • 550
  • 1
  • 7
  • 23
0

This is because phonegap won't take external urls .For phonegap older versions below 2.x we need to set url in cordova.plist like this.

ex:*.google.co.in(u can put your url after *. this) and OpenAllWhitelistURLsInWebView---to ---YES.

Nazik
  • 8,696
  • 27
  • 77
  • 123
DC9999
  • 29
  • 2