I've got a NodeJS script which spins up a ngrok instance, which starts the ngrok binary.
However I'm needing to be able to return back the automatically generated url. I can't find anywhere in the documentation about how to do this.
for example, when you run ngrok http 80
it spins up, generates you a random unique url each time it starts
This question is kinda old, however, I thought to give another more generic option as it doesn't require NodeJS
curl --silent --show-error http://127.0.0.1:4040/api/tunnels | sed -nE 's/.*public_url":"https:..([^"]*).*/\1/p'
This one just inspects the response of calling api/tunnels
by applying text processing (sed
) to the resulted text and identifies the public URL.
ngrok serves tunnel information at /api/tunnels
. So you can get it like so:
json=$(curl -s http://127.0.0.1:4040/api/tunnels);
node -pe "var data = $json; data.tunnels[0].public_uri"
=> https://719c933a.ap.ngrok.io
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