Ionic3(Angular4) CORS on an emulator

2019-07-11 05:49发布

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.

Thanks

1条回答
beautiful°
2楼-- · 2019-07-11 06:42

under your config.xml give the location of your localhost

eg:

<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" />

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

"proxies": [{
        "path": "/rest",
        "proxyUrl": "http://10.10.10.1:8081/rest"
    }]
查看更多
登录 后发表回答