Access localhost from Remote Device
Prerequisite: Your website is currently on <code>http://<i>localhost</i>:<b>8081</b>/</code> with a tool like live-server
a) Publish on Same Network
Within the same network, you can access your machine with your current ip address or hostname. You can find the ip address running ipconfig | grep IPv4
or the hostname by sending a ping -a
to that ip.
<pre><code>http://<i>192.128.1.18</i>:<b>80</b>/
http://<i>hostname</i>:<b>80</b>/</code></pre>
Note: For best results, use port 80, connect on a private network, and check your firewall settings.
b) Publish on Any Network (easier)
-
Opt 1 - You can use ngrok to provide port forwarding over ngrok's public facing ports
Download ngrok and run the following command:
<pre><code>$ ./ngrok http <b>8081</b>
</code></pre>
<img src="https://i.stack.imgur.com/rkYfE.png" width="450" />
-
Opt 2 - You can use localhost.run to create a ssh tunnel with the following command:
<pre><code>ssh -R 80:localhost:<b>8081</b> <i>kylemit</i>@ssh.localhost.run
</code></pre>
<img src="https://i.stack.imgur.com/lAQ9N.png" width="450" />
Access Remote Device from Local Dev Tools
To connect your browser dev tools with a connected device, follow the instructions at Get Started with Remote Debugging Android Devices
-
On your phone, enable Developer Options & USB Debugging
-
Plug your phone into your computer via USB and set the protocol (not File / Media Transfer)
-
Open Dev Tools > More Tools > Remote Debugging (try here if Device Not Detected)
<img src="https://i.stack.imgur.com/pJTw5.png" width="450" />
-
Find your site and Click Inspect which will open up a new inspector window
<img src="https://i.stack.imgur.com/EtrqL.png" width="450" />
Further Reading: