Main
Access localhost on Mobile
As you know, If I am working with url like http://localhost:8080
It doesn’t work on mobile. So, I have to try another way. After some research, I find something related:
localhost
is a hostname which points to127.0.0.1
by default and also can be changed.
Normally, we are using the same WIFI on our computer and mobile. So, in my case,
- I use command
ipconfig
and got the ip192.168.x.x
. - I add
--host 192.168.x.x
in my package.json scripts like this:
{ |
- If you aren’t using package.json, you can directly replace
localhost
to192.168.x.x
in the url. - Then I open the url
http://192.168.x.x:8080
on my computer and mobile. Both work!