Skip to content

Commit 3b7b4cb

Browse files
committed
fix: prevent persisting degraded exposure mode and align loopback hostname checks
- Do not persist 'local-only' fallback when 'network-accessible' was requested but no LAN address was available, preserving the user's preference for the next restart. - Add startsWith('127.') check to isLoopbackHostname in http.ts to match the broader 127.x.x.x coverage in ServerAuthPolicy.
1 parent 9f966e4 commit 3b7b4cb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

apps/desktop/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ async function applyDesktopServerExposureMode(
220220
...(advertisedHostOverride ? { advertisedHostOverride } : {}),
221221
});
222222

223+
let degraded = false;
223224
if (mode === "network-accessible" && exposure.mode !== "network-accessible") {
224225
if (options?.rejectIfUnavailable) {
225226
throw new Error("No reachable network address is available for this desktop right now.");
226227
}
227228
mode = "local-only";
229+
degraded = true;
228230
}
229231

230232
desktopServerExposureMode = exposure.mode;
@@ -241,7 +243,7 @@ async function applyDesktopServerExposureMode(
241243
backendEndpointUrl = exposure.endpointUrl;
242244
backendAdvertisedHost = exposure.advertisedHost;
243245

244-
if (options?.persist || exposure.mode !== mode) {
246+
if (!degraded && (options?.persist || exposure.mode !== mode)) {
245247
writeDesktopSettings(DESKTOP_SETTINGS_PATH, desktopSettings);
246248
}
247249

apps/server/src/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function isLoopbackHostname(hostname: string): boolean {
3434
.trim()
3535
.toLowerCase()
3636
.replace(/^\[(.*)\]$/, "$1");
37-
return LOOPBACK_HOSTNAMES.has(normalizedHostname);
37+
return LOOPBACK_HOSTNAMES.has(normalizedHostname) || normalizedHostname.startsWith("127.");
3838
}
3939

4040
export function resolveDevRedirectUrl(devUrl: URL, requestUrl: URL): string {

0 commit comments

Comments
 (0)