Exist possibility of implement or configure CORS in the server. currently i've been had the follow problem:
i've tried several thing in the client. por example:
var headers = new Headers();
headers.append('Access-Control-Allow-Origin' , '*');
headers.append('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT');
headers.append('Accept','application/json');
headers.append('content-type','multipart/form-data');
this.http.get(url, { headers: headers, withCredentials: true}).subscribe(res => {
//alert(res);
alert(JSON.stringify(res));
},
(error) => {
alert(JSON.stringify(error));
});
}
Someone recommendation me:
there is a native plugin that can “proxy” the HTTP requests using native code, so CORS can be completely bypassed:
Read more here: cordova-plugin-http.
The problem with this solution is than that plugin not work with form-data for send the JSON of the APIs