Ionic app can't reach REST service


#1

Hi, I am running a Spring Boot application on my localhost that provides a REST service. To debug easliy, I use ngrok (https://ngrok.com) to create a tunnel between the device I am running on and my localhost with a provided port (localhost:8080 for me). Ngrok fowards trafic through a link like this: http://88dd0816.ngrok.io/my_rest_calls_here. So when I want to perform a GET request I would simply use:

http://88dd0816.ngrok.io/my_get_call

And it would return whatever I expect from it. Now, I had to update my Ionic/Cordova, my android platform and a bunch of plugins and since I have reinstalled (!, I couldn’t update due to other issues) I can no longer reach my REST service. If I try to perform a REST call by just using a similair call from above, in the browser, I get data back. If I use Ionic Serve (in browser again), I get data back. But when I run it on a android device (Ionic cordova run android) I get a 404 error saying:

“Response with status: 404 Not Found for URL: http://88dd0861.ngrok.io/period

I have had this working before I reinstalled Ionic so I think I have a wrong configuration of some kind somewhere, but I woulnd’t know what is causing this.

I have tried:

  • Adding INTERNET and ACCESS_NETWORK_STATE to the AndroidManifest.xml

I have:

  • <access origin="*" /> in my config.xml
    

Can anyone help me out on this one?

Thanks in advance.


#2

Do you also have the cordova whitelist plugin?


#3

Hi, I did not have that plugin installed. After using the following command:

ionic cordova plugin add cordova-plugin-whitelist --save

The whitelist plugin was installed and I could connect to my REST service again.

Thanks