I\'m able to access my laptop web server using the Android emulator, I\'m using 10.0.2.2:portno
works well.
But when I connect my real Android phone, th
I achieved this by enabling remote management:
System preferences/sharingYou will see a message similar to this:
some.url.comOn your Android device, you should now be able to go to some.url.com, which delegates to localhost on your Mac. You can also use ifconfig to get the IP address of your Mac.
ngrok (any OS with Node.js)If you don't mind exposing your project with a temporary domain you can use ngrok. Lets say I have an app that runs on localhost:9460 I can simply write
npm install ngrok -g
ngrok http 9460
This will give me:
Session Status online
Update update available (version 2.2.8, Ctrl-U to update)
Version 2.2.3
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://f7c23d14.ngrok.io -> localhost:9460
Forwarding https://f7c23d14.ngrok.io -> localhost:9460
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
I can now reach https://f7c23d14.ngrok.io as a way to remotely view localhost. This is great to share design work or progress with clients.
nginx proxy passIf you are running something like this through nginx proxy_pass it will require a bit more tweaking - this is a hacky approach, but it works for me and I am open to suggestions on improving it:
81 as opposed to 80sudo nginx -s reload
http://youripaddress:81server {
listen 80;
listen 81; # <-------- add this to expose the app on a unique port
server_name ~^(local|local\.m).example.com$;
# ...
}
Reload and visit http://youripaddress:81