Download ngrok
ngrok is your app’s front door—and the fastest way to put anything on the internet.
ngrok is your app’s front door—and the fastest way to put anything on the internet.
Setup an example by making a directory:
mkdir hello-ngrok && cd hello-ngrokInitialize your node project and install the ngrok-node package:
npm init -y && npm install @ngrok/ngrokNow we need a runnable example. Let’s create a new index file:
touch index.jsconst http = require('http');
const ngrok = require('@ngrok/ngrok');
// Create webserver
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end('Congrats you have created an ngrok web server');
}).listen(8080, () => console.log('Node.js web server at 8080 is running...'));
// Get your endpoint online
ngrok.connect({ addr: 8080, authtoken_from_env: true })
.then(listener => console.log(`Ingress established at: ${listener.url()}`));Run your NodeJS app with your ngrok authtoken as an environment variable. Sign up for a free account to get your authtoken.
NGROK_AUTHTOKEN=<token> node index.js