I am suffering exactly the same problem. If I can add some extra info based on my research…
- It seems like Ionic at least up to v3 did support this feature, which they call “service proxies”.
( I had put a link to the ionic documentation here, but strangely the forum does not allow me to link to it! )
https://ionicframework.com/docs/v3/cli/configuring.html
And there are still a lot of tutorials around on the web basing themselves on this.
-
However in the current documentation all mention of these proxies has been removed. But I cannot find any release notes or blog posts about this.
-
Furthermore there is a long-running Issue on GH about this same problem, starting in Ionic 4:
search for /ionic-team/ionic-framework/issues/16233 on github, as the forum does not allow me to post a link.
But the Ionic Team do not appear to be responding on it.
- The responses there all suggest using proxy.conf.json so that ANGULAR (rather than IONIC) can handle proxying. And indeed proxy.conf.json works perfectly for Dev. However for Production deployment on a Mobile device, when you want to use the local server which Ionic runs anyway on localhost, to avoid CORS issues, AFAIK the Angular proxy option is not available.
So then you are forced to switch to the native HTTP client on the device, which has a completely different API, doesn’t even load for desktop development, etc.
Alternatively you can proxy everything through your own backend, but this means additional network traffic and compute work. Plus for some things like Geolocation will not even work.
We are currently evaluating Ionic+Angular for use in a cross-platform development, and in general it is a great solution. However this specific issue is close to being a deal-breaker for us.
In conclusion it seems that, without explicitly stating it, Ionic somehow dropped support for “service proxies” and left people to use the Angular proxy.
Would be really nice if someone from the Ionic team could help clarify things here.