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:
localhostis a hostname which points to127.0.0.1by 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
ipconfigand got the ip192.168.x.x. - I add
--host 192.168.x.xin my package.json scripts like this:
{ |
- If you aren’t using package.json, you can directly replace
localhostto192.168.x.xin the url. - Then I open the url
http://192.168.x.x:8080on my computer and mobile. Both work!