I understand that you can access your computer's local site from a mobile device running on the same network by entering your computer's IP address (with relevant local port) into the address bar. However, I often use subdomains for development. On my local I access subdomains using lvh.me. For example:
blog.lvh.me
However, this will not work for mobile because lvh.me is redirecting to the IP 127.0.0.1 .
Is there a way to access a subdomain on an IP address? Essentially, doing the same thing as the above code but allowing for a dynamic IP address depending on the IP my computer has at the time?
Running localhostNavigate to http://yourname.local:8000 on your phone and you're all set!
You need to set your /etc/hosts or C:\Windows\system32\drivers\etc\hosts (as administrator) to reflect the "subdomain". So add 127.0. 0.1 dev. localhost to either file (depending on your platform).
Accessing the Subdomain MenuLog in to your Just Host cPanel account. Click the Domains tab at the top of your account. Click On Subdomains on the submenu.
So, after continuing research, I found an awesome tool that allows for exactly the above functionality:
xip.io
For example, if my computer has the IP address of 124.4.1.3
and I was running a web server at blog.lvh.me
, where lvh.me redirects to localhost or 127.0.0.1
, I could access my computer's localhost from another device on the network using blog.124.4.1.3.xip.io
I hope that helps someone!
Sidenote: The app in question was running on a rails server and the above setup required the following setting to be added to the environments/development.rb
file:
config.action_dispatch.tld_length = 5
As rails was running on port 3000, this also required a url like:
blog.124.4.1.3.xip.io:3000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With