You can integrate Tunnelmole directly into your Node.js application (requires Node 16.10+).
Installation
npm install --save tunnelmole
Implementation
Import the tunnelmole function and call it with a configuration object. The function is async and returns the public URL. It starts the tunnel in the background and does not block the rest of your code execution.
ES Module Import
import { tunnelmole } from 'tunnelmole';
CommonJS Import
const tunnelmole = require('tunnelmole/cjs');
Basic Usage
const url = await tunnelmole({
port: 3000
});
// url = https://idsq6j-ip-157-211-195-169.tunnelmole.net
Usage with a custom domain
const url = await tunnelmole({
port: 3000,
domain: '<your tunnelmole domain e.g. mysite.tunnelmole.net>'
});
const url = await tunnelmole({
port: 3000
});