Meet with CORS issues in Ionic


#1

Hi all,
I am very new to ionic framework. I called the api from server and I got the error like that.

XMLHttpRequest cannot load https://xxx. No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8100’ is therefore not allowed access. The response had HTTP status code 400.

I run with ‘ionic serve’ and currently I avoid this problem with CORS plugin from chrome. But when I test on device or emulator, I cannot avoid. I already put the following code in ionic.config.json.

“proxies”: [{
“path”: “/api/”,
“proxyUrl”: “https://xxx.com/api/
}]

But still remain the same. What should I do more. I spent the whole day for researching, fixing but it waste time only that I cannot solve it yet. Please help me how to over this problem. Thank you so much.