Skip to content

Commit 428913d

Browse files
committed
Fix: fall back to desktop pairing URL for HTTP endpoints
hostedPairingUrl (via buildHostedPairingUrl) always returned a string when endpointUrl was truthy, making the ?? fallback to resolveDesktopPairingUrl unreachable dead code. This caused all shareable pairing links to point to the hosted HTTPS app even for HTTP LAN backends, where browsers block mixed content. Add isHostedPairingCompatible check so resolveHostedPairingUrl returns null for non-HTTPS endpoints, allowing the nullish coalescing to correctly fall through to the direct desktop pairing URL.
1 parent 34102d3 commit 428913d

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

apps/web/src/components/settings/ConnectionsSettings.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,18 @@ function resolveDesktopPairingUrl(endpointUrl: string, credential: string): stri
250250
return setPairingTokenOnUrl(url, credential).toString();
251251
}
252252

253-
function resolveHostedPairingUrl(endpointUrl: string, credential: string): string {
253+
function isHostedPairingCompatible(endpointUrl: string): boolean {
254+
try {
255+
return new URL(endpointUrl).protocol === "https:";
256+
} catch {
257+
return false;
258+
}
259+
}
260+
261+
function resolveHostedPairingUrl(endpointUrl: string, credential: string): string | null {
262+
if (!isHostedPairingCompatible(endpointUrl)) {
263+
return null;
264+
}
254265
return buildHostedPairingUrl({
255266
host: endpointUrl,
256267
token: credential,

0 commit comments

Comments
 (0)