joplin-notes/joplin notion extension/Web Development/nodejs/ngrok.md
2026-11-04 00:33:23 +05:30

52 lines
No EOL
1.3 KiB
Markdown

ngrok
https://reyhann.medium.com/how-to-expose-your-localhost-server-using-ngrok-9928ac2e26b8
https://www.npmjs.com/package/ngrok
- adding token through command
`ngrok config add-authtoken <TOKEN>`
```js
const PORT = process.env.PORT || 8080;
(async function () {
try {
await ngrok.authtoken(token);
const url = await ngrok.connect(PORT);
console.log("url: ", url);
} catch (err) {
console.log("err: ", err);
}
})();
```
- for multiple accounts in same machine
https://jd-bots.com/2022/03/04/how-to-use-multiple-ngrok-accounts-on-one-computer-in-windows/
`ngrok http 80 -config="C:\Users\jagdish\.ngrok2\my-ngrok-2.yml"`
format of `ngrok.yml`
```yml
version: "2"
authtoken: <AUTH_TOKEN>
```
- in shell
ngrok http 80 (here 80 is port number)
- in termux
to fix "failed get HOME directory"
first you need to type "whoami" without quote in your termux.
that will showed the user
~ $ whoami
u0_a185l
&nbsp;
copy the output (u0_a185l) for me.
than add the user to path by typing "export USER=u0_a185l"
~ $ export USER=u0_a185
enter.
and re-run ngrok
~ $ ./ngrok
or
https://github.com/Yisus7u7/termux-ngrok/
- using wifi instead of mobile data in termux
https://www.youtube.com/watch?v=EGaZ9SajayY
simply use proot-distro and use ngrok from there, ngrok if installed in termux will work just have to configure auth-token separately