Guys. This is ridiculous. Iāve just spent an hour dredging through Stack Overflow and this forum. As far as I can tell, NOBODY knows how to get Proxies to work for Ionic 4. Can someone from ionic maybe put together a demo app with the right stuff in it and post it somewhere. Thousands of hours are being wasted swearing, that should be spent telling other people how great ionic isā¦
Personally, Iām trying to use the angular httpClient. I want to create a mobile app and a PWA in the end. I like the way httpClient uses observables. So, I spent about a day or 2, tearing out all the native ionic http stuff. According to at least 50% of the opinionated masses (yes the other 50% were on the fence), this is the right thing to do, for more reasons that I care to elaborate here. However, you know where this is goingā¦ I get a CORS error on my device when I run devApp or ionic run, so I canāt debug on the device. And I have no idea if it will work when built in the end. Since my app is in tatters right now, I just donāt have the energy to try.
So, adding proxies to your ionic.config.json doesnāt work.
Creating a proxy.conf.json file which holds a target doesnāt work, no matter whether you point to it from within your angular.json, or you add it explicitly to the command when you run the serve.
So Iām left with no option but to go back to using the native http and sucking up all the above (not actually) mentioned negatives.
EDIT
Iāve gone back to
import { Http, Headers, Response } from ā@angular/httpā;
and CORS errors vanishes. I have no idea why, nor do I want to. Perhaps soetime in 2023 when someone has figured out how to get httpClient to work, Iāll upgrade again.