A minimal Node.js app demonstrating the ngrok JavaScript SDK.
- An ngrok account.
- Your ngrok auth token.
- Node.js installed on your machine.
-
Install dependencies:
npm install
-
Create a
.env
file from the example:cp .env.example .env
-
Add your ngrok auth token to the
.env
file:NGROK_AUTHTOKEN=your_actual_authtoken_here
-
Reserve a domain in the ngrok dashboard and add it to the
.env
file:NGROK_RESERVED_DOMAIN=your_actual_domain_here
-
Start the Node.js service:
npm run service
-
In another terminal, start the ngrok agent endpoint:
npm run endpoint
The ngrok agent endpoint will output a URL that forwards traffic to your local app.
service.js
- Basic Node.js HTTP serverendpoint.js
- ngrok agent endpoint configuration with OAuth.env.example
- Environment variable template