I have Cordova > 4.0.0, so it has CSP and Whitelist security measures.
In the browser I can make the request to the API, but in an Android device it gives me this error:
file:///http:/xxx.xxx.xxx/api/Login/DoLogin
Failed to load resource: net::ERR_FILE_NOT_FOUND
I searched for a solution, but nothing worked.
My config.xml has this fields (according to Cordova Whitelist Plugin documentation):
<allow-navigation href="*" />
<allow-intent href="*" />
<access origin="*" />"
INFO: I tryed multiple combination's of this parameter's, with the URL of the Api.
(Ex: <access origin="http://xxx.xxx.xxx/" subdomains="true" />
)
In my Index.html I have this CSP:
<meta http-equiv="Content-Security-Policy"
content="default-src *; style-src * 'self' 'unsafe-inline' 'unsafe-eval';
script-src * 'self' 'unsafe-inline' 'unsafe-eval';">
INFO: In here I have tried other combination's of CSP according to Cordova Whitelist Plugin
So, before anyone ask I have installed:
- cordova-whitelist-plugin
And using Restangular for the requests.
I can't figure it out, can someone help me?
EDIT: Request Code
var baseLogin = Restangular.all('http:/xxx.xxx.xxx/api/Login/DoLogin');
dataApi.doLogin = function (var1, var2, var3, var4, var5) { // $http() returns a $promise that we can add handlers with .then() var parameter = null; parameter = { var1: var1, var2: var2, var3: var3, var4: var4, var5: var5 }; return baseLogin.post(parameter); };
I use Ionic, so it has CORS issues in browser, to resolve that I use a proxy in ionic.project file, but it's only called in the browser, in the device it is not using this.