Skip to content

fix(sweetlink): stop probing ws://localhost from remote page origins - #44

Merged
ytspar merged 1 commit into
mainfrom
fix/sweetlink-localhost-candidates
Oct 20, 2026
Merged

ytspar merged 1 commit into
mainfrom
fix/sweetlink-localhost-candidates

Conversation

@ytspar

@ytspar ytspar commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Problem

buildSweetlinkWsUrlCandidates always ended the candidate list with a ws://localhost:<port> fallback. For pages served from remote origins (factory preview hostnames, tunnel URLs), that dial targets the viewer's machine:

  • it always fails (the daemon is not on the viewer's machine),
  • on macOS 15+ it triggers the per-origin Local Network permission prompt ("… wants to Access other apps and services on this device") — observed on the FE-1750 factory pricing preview.

Fix

Gate the ws://localhost:* candidates on the page origin being a local development hostname (localhost/127.0.0.1/*.localhost/*.test — reusing the existing isLocalDevelopmentHostname). Remote origins now attempt same-origin endpoints only (wss://<host>/__sweetlink), which is also the correct priority for the factory preview WebSocket relay (DEV-14160). Explicit wsUrl overrides remain honored on any origin.

Local dev behavior is unchanged (all existing local-origin tests pass as-is).

Validation

  • vitest run packages/sweetlink/src/types.test.ts — 36/36
  • vitest run packages/devbar/src — 1159/1159
  • New regression test covers the wip-hostname shape and the wsUrl-override case.

The candidate builder always appended a ws://localhost:<port> fallback.
On remote origins (factory preview hostnames, tunnels) that dials the
viewer's own machine: it always fails, and on macOS 15+ it triggers a
per-origin Local Network permission prompt.

Gate localhost candidates on the page origin being a local hostname
(localhost/127.0.0.1/*.localhost/*.test); remote origins now attempt
same-origin endpoints only. Explicit wsUrl overrides are unaffected.
@ytspar
ytspar merged commit 408b43b into main Oct 20, 2026
1 check passed
@ytspar
ytspar deleted the fix/sweetlink-localhost-candidates branch October 20, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant