When I run
ionic cordova run android -lcs
and I try to access api endpoints that are not from localhost, I get null object responses. However, when I use
ionic cordova run android
my api endpoints are accessed without error.
I am creating an Ionic 2 app and I am testing on an Android Samsung S7 phone.
How can I get my api endpoints to be accessed using livereload?
Fix the CORS issue.
You can do that by setting the correct headers or use a service proxy in the CLI: https://github.com/ionic-team/ionic-cli#service-proxies
I tried using proxies before this way but it didn’t work. That is for when you accessing local servers but I am accessing external servers that are hosted not on localhost, but on their own address.
Yes, just define a proxy for that address. Then the proxy address is localhost and CORS doesn’t trigger.