-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngrok.js
32 lines (30 loc) · 877 Bytes
/
ngrok.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const ngrok = require('ngrok')
const path = require('path')
const fs = require('fs')
const dotenvFilePath = path.resolve(__dirname, `./.env`)
const dotenv = require('dotenv')
if (fs.existsSync(dotenvFilePath)) {
dotenv.config({
path: dotenvFilePath,
encoding: 'utf8'
})
}
ngrok
.connect({
addr: process.env.PORT,
authtoken: process.env.NGROK_AUTH_TOKEN,
subdomain: process.env.NGROK_SUBDOMAIN,
region: process.env.NGROK_REGION
})
.then(url => {
console.log(`👩🏻💻 Webhook URL for Google OAUTH2: ${url}/auth/google`)
console.log(`💳 App URL to see the demo in your browser: ${url}/`)
})
.catch(err => {
if (err.code === 'ECONNREFUSED') {
console.log(`⚠️ Connection refused at ${err.address}:${err.port}`)
} else {
console.log(`⚠️ ${JSON.stringify(err)}`)
}
process.exit(1)
})