Cordova 应用未在 Android 上点击 API - net::ERR_CONNECTION_REFUSED

Cordova app not hitting API on Android - net::ERR_CONNECTION_REFUSED

我查看了很多类似的问题,但 none 似乎对我有用。我们的应用程序发出 2 个 API 请求 - 第一个请求将 OAuth 代码获取到我们的 API(工作正常),其他将代码发送到 Rails API(这是失败)。

我正在发帖到 http://localhost:3000/api/v1/users/auth/openid_connect/callback

但是得到net::ERR_CONNECTION_REFUSED。但是,当 运行 on iOS.

时,这很好用

我的配置目前有:

<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

我试过添加 <allow-intent href="http://localhost:3000/api/v1/*" /><allow-intent href="http://127.0.0.1:3000/api/v1/*" /> 甚至完整的 openid_connect/callback URL 但 none 似乎有效。

在我的index.html中,我有

<meta http-equiv="Content-Security-Policy" content="default-src * 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; connect-src * 'unsafe-inline'">

问题是我在配置中如何处理 access origin 还是我的 Content-Security-Policy 有误?

要关闭问题,错误是 Android 似乎不知道如何处理 localhost。将域更改为 http://10.0.2.2 解决了问题。