This post describes how you can make a localhost-url accessible from the public Internet with ngrok on Windows. There is times when you need to test a payment api or another api that makes callbacks to a public url, by using ngrok you can test your implementation on your local development machine. ngrok exposes local computers behind NATs and firewalls to the public Internet over secure tunnels.
Install ngrok
You need to download ngrok and unzip the file to a folder on your computer. It is just one exe-file that you can place wherever you want on your computer.
Get public url:s
Open a website project in Visual Studio, start a debugging session and copy the localhost address (localhost:55587). Open a command prompt as an administrator and browse to the folder where ngrok.exe is located. Type ngrok http [PORT] –host-header=localhost:[PORT] and press enter.
Microsoft Windows [Version 10.0.17134.648]
(c) 2018 Microsoft Corporation. Med ensamrätt.
C:\WINDOWS\system32>d:
D:\>cd Program
D:\Program>ngrok http 55587 --host-header=localhost:55587
When you press enter you will get the following response with public url:s that you can use as public callback url:s (https://72907935.ngrok.io) or just to test your website from another computer. You must keep the command prompt open while you are testing.
ngrok by @inconshreveable (Ctrl+C to quit)
Session Status online
Session Expires 7 hours, 59 minutes
Update update available (version 2.3.18, Ctrl-U to updat
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://72907935.ngrok.io -> localhost:55587
Forwarding https://72907935.ngrok.io -> localhost:55587
Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00