Test localhost on your phone without typing a URL!
- Install:
- libqrncode (
brew install libqrencode) - jq (
brew install jq) - ngrok (download the binary)
- libqrncode (
- Put the following code in
~/.bash_profileor wherever you prefer to configure your shell- Don't forget to
sourceafterwards!
- Don't forget to
- Start an ngrok tunnel (for example:
ngrok http 3000for an app running atlocalhost:3000) - In another terminal, run
nqr. The QR code corresponding to your ngrok URL will open in Preview. - Open a new tab in Chrome on your phone, tap 'Search or Type URL', then tap the QR button just above the keyboard. Scan the code!
- On iPhone, you can also type
qrinto Spotlight search to bring up Chrome's QR reader directly.
- On iPhone, you can also type
function qr {
echo "Creating QR code for $1";
qrencode -o /tmp/qr.png "$1";
open /tmp/qr.png
}
export -f qr
function ngrok_https_url {
curl -s http://127.0.0.1:4040/api/tunnels | jq -r '.tunnels | .[] | select(.proto | contains("https")) | .public_url'
}
export -f ngrok_https_url
alias nqr='qr `ngrok_https_url`'- Tested on macOS Sierra (10.12.6)