简体   繁体   中英

Phonegap whitelist domains for Android

Using phonegap version 6.5.2 I'm trying to whitelist domains for an Android application's data and media requests.

In config.xml I have:

<access origin="*" />

as well as a few specific domains:

<access origin="http://example.com" />
<access origin="http://fonts.googleapis.com" />

I've also tried putting this in my root index.html , which should allow all domains, right?:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

But I'm still getting nothing but 404 errors when my app tries to load content.

What gives?

Not sure where the problem was, but after uninstalling and re-installing the whitelist plugin, and restarting the simulator, everything seems to be working. Thanks @Gandhi for pointing me in that direction.

The basic rule to follow in case of 404 errors in cordova android app are as follows:

  • Check whether cordova whitelist plugin is installed properly

  • Check whether allow access origin is set properly in config.xml

  • Check whether content security policy is set properly in your HTML files

These steps should address almost all the problems related to 404 errors provided the requested URLs are up and running. Hope it helps. Cheers

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