Hi, i have configured a proxy in the proxy.conf.json file and added it to angular.json.
If i serve the app everything works just fine, but if i use “ionic cordova run android -l” the proxy doesn’t work anymore.
Accually i been annoyed by a few problems like this since ionic 4, where diferents way or trying the app give very different results.
Any walkaround?
As far as I know, as in v3, this proxy was never suppose to work while running cordova no? it was only intended to solve cors problem while running ionic serve
I Don’t think so. If that’s true, I shouldn’t have cross origin messages
Here, https://blog.ionicframework.com/handling-cors-issues-in-ionic/, it’s a ionic 3 article that explains that ionic serve and ionic run can give cors errors, so you have to use a proxy. As i said earlier, in Ionic 4 the proxy only works in ionic serve and when i run ionic cordova run the proxy doesn’t work and i have a CORS error .
Ionic 4 is a cruel mistress!
Thx for pointing out, I always and still only use the proxy for ionic serve
assuming the rest should works as if I publish my app respectively without. Unfortunately I will not be able to help that much then. Maybe you could give a try adding @ionic/cli-plugin-proxy
see https://ionicframework.com/docs/cli/configuring.html#using-a-proxy
Unfortunately @ionic/cli-plugin-proxy doesn’t work either. In general i use ionic serve too, but i’m having a rought time with ionic serve and the ion refresher (Ionic 4 - Ion refresher bug) so i wanted to test the app on ionic run… what a pitty.
Even if i use ionic cordova run browser proxy get all messed up. Instead of http proxy-address/address-you-want, the app is trying of http localhost:8000/proxy-address/address-you-want
Sorry no idea, only thing I could say is that the Angular proxy used in Ionic v4 for ionic serve
just works fine, I could confirm that. For ionic run
like I said above I don’t know. Good luck, let me know if you find a solution!
Seems like the new Ionic cli version 4.3.0 solved the bug
Hi:
I have several issues with the new way to proxy:
- I need t define each and every sub URL/folder that I am using in the json instead everything is under one configuration.
Say I have /api as the base and also: “/api/tours” & “/api/tourists”.
I need to define each and every api therwise they will all go to /api request
because the mode is debug it says it converts to that:
http://localhost:8100/api -> https://url.com/api
http://localhost:8100/api/tours -> https://url.com/api/
http://localhost:8100/api/tourists-> https://url.com/api/
They all go to the /api request!!!
- The requests get empty responses and cause errors:
core.js:14597 ERROR Error: Uncaught (in promise): SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at resolvePromise (zone.js:831)
at resolvePromise (zone.js:788)
at zone.js:892
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
at Object.onInvokeTask (core.js:16147)
at ZoneDelegate.push…/node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
at Zone.push…/node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
at drainMicroTaskQueue (zone.js:601)
Please fix that 10x
Fixed:
Go to package.json and change the line: (“scripts” json)
“start”: “ng serve”,
to—>
“start”: “ng serve --proxy-config proxy.config.json”,
and do in the CMD: npm start
instead of ionic serve. and it will go to port 4200.
if somebody has better solution like it worked in the past with ionic serve than please add to the thread. This is what I do for now