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.