Hello,
I’m developping a connected application with Ionic.
So, I have a local webservice running on my computer (http://localhost:8100/xxxx)
In my app, I make call to this webservice :
- this works when I launch the app with ionic service
- this doesn’t work when I launch the app on my android device (with ionic run and ionic run -l)
It’d be cool if you could help me.
can you even access it via phone ? I think its a problem with your network settings
No, when I run it on a phone, it doesn’t work.
THat’s what I was thinking. As the host of the api requests is localhost, the phone make call locally, not on my computer.
How to call the server which is on my computer ?
@ebikhafan is half right, but the problem will be because your phone is trying to access http://localhost - it doesn’t know what this is, get your IP address of your computer and replace localhost with it, this will allow your phone to access the resources.
Also look into using ionic proxy http://ionicframework.com/docs/cli/test.html
1 Like
yes :)) I forgot to mention :)) thanks
In linux you should just change the address to http://your-local-ip:8100/xxxx
in windows (at least for me) I had to change some network settings
Hello friend, tell me how you did it to connect to your web service. Could you please teach me? is that I have been trying and I have not yet achieved it.
diargal0307@hotmail.com is my mail in case you share your code with me. Thank you.
@diargal
- Connect the Mobile and your Computer to the same network/wifi.
- find your system(computer) IP.
- while taking the mobile build in the config file change the http://localhost:8100/ into http://YOUR_IP:8100/ eg: ( http://192.168.100.34:8100/)
Now you can access your local server form your mobile.
2 Likes
Exactly what I wanted to thank you @diargal
So in step 3 what you meant was to start ionic serve like
ionic serve --address=192.168.16.59
and from my iPhone just go to 192.168.16.59:8100
now I can test my ionic web app (PWA) from iphone