【发布时间】:2020-03-10 23:11:46
【问题描述】:
我有一个使用 Apache Cordova 制作的应用程序(基本上,它将 HTML/CSS/JS 网站变成了一个应用程序)。它向我在 PC 上本地运行的 REST API 发送一个简单的 GET 请求。我正在使用 PC (192.168.x.x) 的本地(不是本地主机)IP 和正确的端口,但它似乎不起作用。但是,我可以通过手机上的浏览器“手动”输入地址和端口。<uses-permission name="android.permission.INTERNET" /> 已经在 .xml 文件中。我的防火墙已停用,我的网络设置为“专用网络”。
EDIT 20.3.2020 13:08:我意识到我正在查看错误的 .xml 文件,但问题仍然存在。为清楚起见,添加整个 config.xml 文件。
<xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<feature name="Whitelist">
<param name="android-package" value="org.apache.cordova.whitelist.WhitelistPlugin" />
<param name="onload" value="true" />
</feature>
<uses-permission name="android.permission.INTERNET" />
<name></name>
<content src="index.html" />
<access origin="*" />
<allow-intent 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:*" />
<allow-intent href="market:*" />
<preference name="loglevel" value="DEBUG" />
</widget>
【问题讨论】: