【问题标题】:Phonegap Ionic app not working from device with rest APIPhonegap Ionic 应用程序无法在具有其他 API 的设备上运行
【发布时间】:2016-12-29 20:26:37
【问题描述】:

现在我正在尝试使用护照基本策略进行登录调用以表达 rest API,并且在浏览器上一切正常,但从 Phonegap 的设备上它不起作用。我试图删除并添加 cordova-plugin-whitelist 插件。向 config.xml <allow-navigation href="http://*/*" /> 添加了以下标签。并添加到 index.html <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> 我进行了 cors 设置。但这没有帮助。我还发现我的请求在调用中包含“/proxy/”。

这里是示例:http://192.168.1.189:3000/proxy/http%3A%2F%2F127.0.0.1%3A8080%2Fapi%2Fauth%2Flogin

还好吗?这是我从服务器得到的:

提前致谢。

【问题讨论】:

    标签: angularjs cordova ionic-framework


    【解决方案1】:

    我花了一些时间搜索并找到了解决方案: 在我的 ionic app.js 文件中,我只是更改了以下行:

    const BASE_URL = 'http://127.0.0.1:8080/api';
    

    到:

    const BASE_URL = 'http://192.168.1.102:8080/api';
    

    它对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2019-12-17
      • 1970-01-01
      • 2017-08-18
      相关资源
      最近更新 更多