【问题标题】:Ionic2/Angular2 CORS settingsIonic2/Angular2 CORS 设置
【发布时间】:2016-10-16 00:06:48
【问题描述】:

请帮助我在 Ionic2/Angular2 应用程序上使用 CORS。 我正在尝试使用 http 'GET' 请求获取数据。 当我在笔记本电脑上运行“$npm run build”时,我得到了预期的响应。 当我运行'$ cordova run android'时,我总是得到'Response with status: 0 for URL: null'。 这是代码sn-p:

this.http.get('https://httpbin.org/ip')
        .subscribe((data: any) => {
            this.result = data._body; // {"origin": "31.43.103.88"} on laptop
        }, error => {
            this.result = error; // 'Response with status: 0 for URL: null' on android
        });

谢谢。

【问题讨论】:

  • 您是否设法从浏览器访问您的 IP?验证端口是否也未被防火墙阻止。如果仍然无法正常工作,请参阅此帖子:stackoverflow.com/a/36124935/2549619

标签: cordova angular cors


【解决方案1】:

嗯……看来是我自己想出来的。 我这样做了: 1) 离子平台 rm android 2)离子平台添加android 这很奇怪,但就像一个魅力。

【讨论】:

    猜你喜欢
    • 2017-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-27
    • 2016-05-30
    • 1970-01-01
    相关资源
    最近更新 更多