模拟器上的 Ionic3(Angular4) CORS [英] Ionic3(Angular4) CORS on an emulator

查看:29
本文介绍了模拟器上的 Ionic3(Angular4) CORS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个 genymotion 模拟器上测试 Ionic 3 应用程序.顺便说一句,由于 CORS,http 请求不起作用.我以为服务器有问题.但我在使用 ionic 2 应用程序检查后确认服务器没有问题.Ionic 3 应用程序的 Http 请求在真实设备和浏览器上运行良好.你想让我知道我错了吗?对不起我的英语不好.

I'm testing Ionic 3 app on a genymotion emulator. Btw http request doesn't work because of CORS. I thought that a sever has a problem. But I confirmed that a server has no problem after checking it with ionic 2 app. Http request of Ionic 3 app works well on a real device and on a browser. Would you like to let me know what I am wrong? sorry for my poor english.

谢谢

推荐答案

在你的 config.xml 下给出你的本地主机的位置

under your config.xml give the location of your localhost

例如:

<content src="http://10.10.1.1:8100" />
<access origin="http://10.10.1.1:8100" />
<allow-navigation href="http://10.10.1.1:8100" />

进一步确保您在 ionic.config.json 下添加代理 url

further more make sure you add the proxy url under ionic.config.json

"proxies": [{
        "path": "/rest",
        "proxyUrl": "http://10.10.10.1:8081/rest"
    }]

这篇关于模拟器上的 Ionic3(Angular4) CORS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆