简体   繁体   中英

Ionic can't run my app from the device browser

I am developing an Android app using ionic. When I execute ionic serve I can see my app on my computer through http://localhost:8100

I checked my ip address using ipconfig and it's 192.168.0.3 , so I tried using this IP from my device ( http://192.168.0.3:8100 ), but I got a 404. I then tried from the very same computer I am developing from, and I got a 404 too!

Funny thing is, ionic uses two servers:

在此处输入图片说明

If I put http://192.168.0.3:35729 I can see live reload server both from my computer and my device. I didn't have to touch anything on my router to forward ports, and both my computer and my phone are on the same network. Note that I cannot access http://192.168.0.3:8100 neither from my phone nor from my computer (the same one I am using to develop)

Also I am serving a REST web service on 8080 from a J2EE app, and I can see it in my device. My app consumes this service, and from the computer, everything works fine. But from the device, although I can use the phone browser to access the REST server, my ionic app gives me another 404 error!

Can anyone point me in the right direction?

You will have to change the address Ionic has configured. Run:

ionic address

Then it will provide you a list of available addresses:

Multiple addresses available.
Please select which address to use by entering its number from the list below:
1) 192.168.0.107 (eth1)
2) localhost

Select your local IP from the available options. This must solve the issue you're facing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM