ngrok / ngrok-javascript

Embed ngrok secure ingress into your Node.js apps with a single line of code.
https://ngrok.com
Apache License 2.0
86 stars 17 forks source link

Node.js: ngrok.forward() issue #125

Closed ballonura closed 1 month ago

ballonura commented 4 months ago

try this command:

await ngrok.forward()

and get this issue:

[Error: failed to connect session: Usage of ngrok requires a verified account and authtoken.
Sign up for an account: https://dashboard.ngrok.com/signup
Install your authtoken: https://dashboard.ngrok.com/get-started/your-authtoken error_code: ERR_NGROK_4018] {
  code: 'GenericFailure',
  error

but when passing manuaaly it work:

{
  authtoken_from_env: false,
  authtoken: 'xxxxx-my-auth-token-my-auth-token-xxxxx'
}

Node.js version: v14.21.3 ngrok version: 3.6.0

salilsub commented 4 months ago

Hi @ballonura , when running your initial command did you have the environment variable NGROK_AUTHTOKEN set ?

ballonura commented 4 months ago

n0pe, how should i set it? i think the sdk itself know how get it.

salilsub commented 4 months ago

In order to connect to the ngrok service, you need to supply a valid authtoken. There are two ways to do this with ngrok-javascript:

  1. Set authtoken_from_env to true (it defaults to false) and set the NGROK_AUTHTOKEN to your authtoken. How you set this environment variable will depend on your OS.
  2. Set authtoken_from_env to false and set authtoken to your authtoken as you did above when you passed manually.
bobzilladev commented 1 month ago

Hello! Looks like this issue has been taken care of, so going to close this ticket out. Feel free to reopen if anything else comes up. Thanks again for writing in!