print out some of the URLs where to reach the server
Massimo Melina committed
Jan 21, 2022 at 15:09 UTC
ca0111118d33bd5921a5bb39b57603336a8faca1
1 file changed
+12
src/listen.ts
+12
@@ -4,6 +4,7 @@ import open from 'open'
4
import { app } from './index'
5
import * as https from 'https'
6
import { watchLoad } from './watchLoad'
7
+import { networkInterfaces } from 'os';
8
9
let firstTime = true
10
let httpSrv: http.Server
@@ -70,6 +71,17 @@ function startServer(srv: http.Server, port: number, secure:string='') {
71
port = ad.port
72
console.log(proto, `serving on port`, port)
73
74
+ const ignore = /^(lo|.*loopback.*|virtualbox.*|.*\(wsl\).*)$/i // avoid giving too much information
75
+ for (const [name, nets] of Object.entries(networkInterfaces()))
76
+ if (nets && !ignore.test(name)) {
77
+ console.log('network', name)
78
+ for (const net of nets) {
79
+ if (net.internal) continue
80
+ const appendPort = port === (secure ? 443 : 80) ? '' : ':' + port
81
+ console.log('-', proto + '://' + net.address + appendPort)
82
+ }
83
+ }
84
+
85
if (firstTime && getConfig('open_browser_at_start') !== false) {
86
open(proto + '://localhost:' + port).then()
87
firstTime = false