【发布时间】:2023-03-11 17:54:01
【问题描述】:
我使用 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');
}
但问题仍未解决。
【问题讨论】:
标签: ionic-framework ionic2 ionic3 ionic-view