fix: (regression 0.55.0) admin/options: no redirection when setting port same as temporary one (8080)
Massimo Melina committed
Jan 12, 2025 at 18:28 UTC
7a80f184f28e663ef57cfa727412fbac01f98a12
1 file changed
+3
-2
admin/src/OptionsPage.ts
+3
-2
@@ -271,7 +271,8 @@ export default function OptionsPage() {
271
return alertDialog("You cannot switch off this port unless you have a working fixed port for " + otherProtocol, 'warning')
272
if (newPort === 0 && !otherIsReliable)
273
return alertDialog("You cannot randomize this port unless you have a working fixed port for " + otherProtocol, 'warning')
274
- if (newPort > 0 && !await confirmDialog("You are changing the port and you may be disconnected"))
274
+ const goingNewPort = newPort > 0 && newPort != loc.port // == loc.port can happen when listening on a temporary port, and the user just set the same port as new config
275
+ if (goingNewPort && !await confirmDialog("You are changing the port and you may be disconnected"))
276
return
277
const certChange = 'cert' in changes || 'private_key' in changes
278
if (onHttps && certChange && !await confirmDialog("You may disrupt https service, kicking you out"))
@@ -280,7 +281,7 @@ export default function OptionsPage() {
281
const ip = ipForUrl(loc.hostname)
282
const path = loc.pathname + loc.hash
283
const redirect = newPort <= 0 ? `${onHttps ? 'http:' : 'https:'}//${ip}:${otherPort}${path}` // jump protocol also in case of random port, because people must know their port while using GUI
283
- : newPort ? `${loc.protocol}//${ip}:${newPort || values[keys[0]]}${path}`
284
+ : goingNewPort ? `${loc.protocol}//${ip}:${newPort || values[keys[0]]}${path}`
285
: await with_(`https://${ip}:${loc.port}${path}`, httpsUrl => // could we be kicked out because of force_https?
286
!onHttps && (changes.force_https ?? data.force_https) && fetch(httpsUrl).then(() => httpsUrl, () => 0)) // only happens if https is working
287
if (redirect) {