Ionic v4 with Credentials true给我cors错误

Ionic v4 with Credentials true给我cors错误,cors,angular6,ionic4,ionic-v1,Cors,Angular6,Ionic4,Ionic V1,Ionic v1 api调用正在使用withCredentials true,但Ionic v4代码无法使用,从而导致访问控制错误 离子v1码 vm.getUser = function (email, password) { return $http({ method: 'POST', crossDomain: true, dataType: "json", url: 'http://localhost:3000/api/login/1', contentType:

Ionic v1 api调用正在使用withCredentials true,但Ionic v4代码无法使用,从而导致访问控制错误

离子v1码

vm.getUser = function (email, password) {
  return $http({
  method: 'POST',
   crossDomain: true,
  dataType: "json",
  url: 'http://localhost:3000/api/login/1',
  contentType: "application/json",
  xhrFields: {
    withCredentials: true
  },
  data: {"email": email, "password": password}
});
 };
**工作**

 getUser(){
this.http.post(this.url, 
 {"email": email,      "password": password},
{headers:{Content-Type:'application/json'}, withCredentials:true});
不工作

Https不是http 如果您的url支持https,您应该使用https,否则它在现代Android设备上无法工作

他们开始阻止它返回几个版本,除非您添加额外的安全设置来允许它

CORS误差 这是因为爱奥尼亚4使用了不同的、更现代的网络视图。它有很多优点,但有一个问题是webview本身强制执行CORS

不过,解决方案不在您的应用程序中。您需要更改运行api的服务器,它需要允许cors策略

您应该阅读,但实际的解决方案将取决于您如何编写登录api

你能避免CORS吗? 阅读:

Web视图强制执行CORS,因此外部服务正确处理跨源请求非常重要。有关更多详细信息,请参阅enable-cors.org和MDN

如果服务器上没有实现CORS,则有一个本机插件可以绕过CORS在本机层执行HTTP请求


谢谢你的回复,1。由于后端存在一些SSL认证问题,我们无法使用https。2.我已经部署了服务器,所以我有没有可能只从客户端解决这个问题。我已经使用本机http插件实现了。如何向后续请求发送cookie。是否替换本机插件中的withCredentials true?我找不到。