响应状态:0 for URL: null

Respon with status: 0 for URL: null

我使用 ionic view legacy 和 http post 没有任何问题。但是在执行 http post 时使用 ionic view pro 进行迁移时会显示错误“Respon with status: 0 for URL: null”.

这是我的一部分 config.xml

    <access origin="*" subdomain="true" />
    <allow-navigation href="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
   
    <plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
    <plugin name="cordova-plugin-statusbar" spec="2.2.2" />
    <plugin name="cordova-plugin-device" spec="1.1.4" />
    <plugin name="cordova-plugin-splashscreen" spec="~4.0.1" />
    <plugin name="cordova-plugin-ionic" spec="^1.1.9">
        <variable name="APP_ID" value="-" />
        <variable name="CHANNEL_NAME" value="Master" />
        <variable name="UPDATE_METHOD" value="auto" />
    </plugin>
    <plugin name="cordova-plugin-whitelist" spec="^1.3.1" />

这个问题是因为 CORS 所以在后端我只是添加:

/* Allow from any origin */
  if (isset($_SERVER['HTTP_ORIGIN'])) {
   header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
   header('Access-Control-Allow-Credentials: true');
   header('Access-Control-Max-Age: 86400');
  }

但是问题还是没有解决。

最后……我通过从 http 更改为 https 并检查 header 发送来解决这个问题。来自 jwt 的 Headher 是我的问题,所以我使用 post 而不是 header.

来更改它