You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-24
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# NodeJS SDK for ngrok
1
+
# Javascript SDK for ngrok
2
2
3
3
[![npm.rs][npm-badge]][npm-url]
4
4
[![MIT licensed][mit-badge]][mit-url]
@@ -42,16 +42,16 @@ pnpm add @ngrok/ngrok
42
42
43
43
1.[Install `@ngrok/ngrok`](#installation)
44
44
2. Export your [authtoken from the ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken) as `NGROK_AUTHTOKEN` in your terminal
45
-
3. Add the following code to your application to establish connectivity via the [connect method](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-connect-minimal.js) through port `8080` over `localhost`:
45
+
3. Add the following code to your application to establish connectivity via the [forward method](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-minimal.js) through port `8080` over `localhost`:
46
46
47
47
```jsx
48
-
// Require ngrok nodejs sdk
48
+
// Require ngrok javascript sdk
49
49
constngrok=require("@ngrok/ngrok");
50
50
// import ngrok from '@ngrok/ngrok' // if inside a module
console.log(`Ingress established at: ${listener.url()}`);
@@ -71,16 +71,16 @@ A quickstart guide and a full API reference are included in the [ngrok-javascrip
71
71
72
72
To use most of ngrok's features, you'll need an authtoken. To obtain one, sign up for free at [ngrok.com](https://dashboard.ngrok.com/signup) and retrieve it from the [authtoken page of your ngrok dashboard](https://dashboard.ngrok.com/get-started/your-authtoken). Once you have copied your authtoken, you can reference it in several ways.
73
73
74
-
You can set it in the `NGROK_AUTHTOKEN` environment variable and pass `authtoken_from_env: true` to the [connect](https://ngrok.github.io/ngrok-javascript/functions/connect.html) method:
74
+
You can set it in the `NGROK_AUTHTOKEN` environment variable and pass `authtoken_from_env: true` to the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method:
Or pass the authtoken directly to the [connect](https://ngrok.github.io/ngrok-javascript/functions/connect.html) method:
80
+
Or pass the authtoken directly to the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method:
81
81
82
82
```jsx
83
-
await ngrok.connect({ authtoken: token, ... });
83
+
await ngrok.forward({ authtoken: token, ... });
84
84
```
85
85
86
86
Or set it for all connections with the [authtoken](https://ngrok.github.io/ngrok-javascript/functions/authtoken.html) method:
@@ -91,42 +91,42 @@ await ngrok.authtoken(token);
91
91
92
92
### Connection
93
93
94
-
The [connect](https://ngrok.github.io/ngrok-javascript/functions/connect.html) method is the easiest way to start an ngrok session and establish a listener to a specified address. The [connect](https://ngrok.github.io/ngrok-javascript/functions/connect.html) method returns a promise that resolves to the public URL of the listener.
94
+
The [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method is the easiest way to start an ngrok session and establish a listener to a specified address. The [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method returns a promise that resolves to the public URL of the listener.
95
95
96
-
With no arguments the [connect](https://ngrok.github.io/ngrok-javascript/functions/connect.html) method will start an HTTP listener to `localhost` port `80`:
96
+
With no arguments the [forward](https://ngrok.github.io/ngrok-javascript/functions/forward.html) method will start an HTTP listener to `localhost` port `80`:
97
97
98
98
```jsx
99
99
const ngrok = require("@ngrok/ngrok");
100
100
// import ngrok from '@ngrok/ngrok' // if inside a module
101
101
102
102
(async function() {
103
-
console.log( (await ngrok.connect()).url() );
103
+
console.log( (await ngrok.forward()).url() );
104
104
})();
105
105
```
106
106
107
107
You can pass the port number to forward on `localhost`:
108
108
109
109
```jsx
110
-
const listener = await ngrok.connect(4242);
110
+
const listener = await ngrok.forward(4242);
111
111
```
112
112
113
113
Or you can specify the host and port via a string:
See [Full Configuration](#full-configuration) for the list of possible configuration options.
@@ -179,10 +179,10 @@ See here for a [Full Configuration Example](https://github.com/ngrok/ngrok-javas
179
179
180
180
### TLS Backends
181
181
182
-
As of version `0.7.0` there is backend TLS connection support, validated by a filepath specified in the `SSL_CERT_FILE` environment variable, or falling back to the host OS installed trusted certificate authorities. So it is now possible to do this to connect:
182
+
As of version `0.7.0` there is backend TLS connection support, validated by a filepath specified in the `SSL_CERT_FILE` environment variable, or falling back to the host OS installed trusted certificate authorities. So it is now possible to do this to forward:
If the service is using certs not trusted by the OS, such as self-signed certificates, add an environment variable like this before running: `SSL_CERT_FILE=/path/to/ca.crt`.
@@ -211,10 +211,10 @@ new ngrok.NgrokSessionBuilder().authtokenFromEnv().connect()
211
211
212
212
### Full Configuration
213
213
214
-
This example shows [all the possible configuration items of ngrok.connect](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-connect-full.js):
214
+
This example shows [all the possible configuration items of ngrok.forward](https://github.com/ngrok/ngrok-javascript/blob/main/examples/ngrok-forward-full.js):
215
215
216
216
```jsx
217
-
const listener = await ngrok.connect({
217
+
const listener = await ngrok.forward({
218
218
// session configuration
219
219
addr: `localhost:8080`, // or `8080` or `unix:${UNIX_SOCKET}`
0 commit comments