fix: https-only configuration didn't open admin-panel
Massimo Melina committed
Dec 24, 2022 at 18:12 UTC
ea0398ba1330ecffaaa847440d50586cd67fa0e8
1 file changed
+13
-2
src/listen.ts
+13
-2
@@ -31,14 +31,25 @@ portCfg.sub(async port => {
31
httpSrv.on('connection', newConnection)
32
printUrls(port, 'http')
33
if (openBrowserAtStart.get())
34
- open('http://localhost' + (port === 80 ? '' : ':' + port) + ADMIN_URI, { wait: true}).catch(e => {
34
+ openAdmin()
35
+})
36
+
37
+export function openAdmin() {
38
+ for (const srv of [httpSrv, httpsSrv]) {
39
+ const a = srv.address()
40
+ if (!a || typeof a === 'string') continue
41
+ const baseUrl = srv.name + '://localhost:' + a.port
42
+ open(baseUrl + ADMIN_URI, { wait: true}).catch(e => {
43
console.debug(String(e))
44
console.warn("cannot launch browser on this machine >PLEASE< open your browser and reach one of these (you may need a different address)",
45
...Object.values(getUrls()).flat().map(x => '\n - ' + x + ADMIN_URI))
46
if (! anyAccountCanLoginAdmin())
47
console.log(`HINT: you can enter command: create-admin YOUR_PASSWORD`)
48
})
41
-})
49
+ return true
50
+ }
51
+ console.log("openAdmin failed")
52
+}
53
54
const considerHttps = debounceAsync(async () => {
55
stopServer(httpsSrv).then()