Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top