Skip to content

Instantly share code, notes, and snippets.

@szkrd
Created February 5, 2018 10:14
Show Gist options
  • Select an option

  • Save szkrd/20e2a3c32653ed2083985a43671595b7 to your computer and use it in GitHub Desktop.

Select an option

Save szkrd/20e2a3c32653ed2083985a43671595b7 to your computer and use it in GitHub Desktop.

Access local dev site from phone in a platform agnostic way

We have the foo.dev url in our hosts file.

If you want to access your dev machine, you will have to add this hostname "somehow" to a hosts file (with the proper ip address): this is not possible on unrooted android or IOS.

To access your machine from your phone, you can do the following:

  1. connect both machines to the same network (probably this is the company wifi)

  2. open a simple server on port 80 and check if the phone can access http://your-host-ip/ (check your firewall settings, be sure to use the wireless interface ip)

  3. install dnsmasq (for linux or mac) or dnsAgent for windows set "foo.dev" to "your-host-ip" (for the wireless interface, probably 192.168.8.10x, do NOT use 127.0.0.1 or localhost or ::1)

  4. phone settings, wireless connection, set DNS manually, use the ip for your dns server (and be sure that dns traffic to that application and port 53 goes through)

  5. turn airplane mode on-off to flush the dns cache (but you still have to wait a bit)

  6. connect to the vpn on both machines (so that you can access backend endpoints)

  7. accept the "cert errors" for all endpoints (open the urls and accept one by one - or use an aggregator endpoint in your app)

  8. open https://foo.dev:3000/ from your phone (do enter the full url manually)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment