fix(desktop): open detected ports over https when the server speaks TLS
AD
4d ago+231+231+012345678901234567890123456789-29-29-01234567890123456789
What & why
Opening a detected port always used http://localhost:<port>. Dev servers that serve HTTPS (for example Vite with a TLS certificate) then fail to load, and .superset/ports.json has no way to set the scheme.
This change detects the scheme when a port is opened:
- New
ports.detectSchemetRPC query in the Electron main process. It tries a TLS handshake tolocalhost:<port>(certificate not verified, because dev certs are usually self-signed, 500 ms timeout) and returns"https"when the handshake completes with a server certificate. Any error, timeout, or plain-HTTP server gives"http". The socket is always destroyed. - New renderer helper
resolvePortUrlcalls it and swapshttp:forhttps:when needed. If the check fails, the originalhttp://URL is used. - Both open paths use it: the new sidebar (
usePortOpenActions, including forwarded remote ports, which probe the local forwarded port) and the legacyMergedPortBadge.
The probe runs only on click, not for every listed port. The copy-URL action in the ports dropdown still copies http://localhost:<port>, because that value is computed synchronously for rendering.
How I tested it
- New unit test
detect-port-scheme.test.ts: a TLS server returnshttps, a plain HTTP server returnshttp, a TCP server that never answers the handshake returnshttp(timeout), and a closed port returnshttp. The test makes a throwaway self-signed certificate withopensslat run time, so no key is committed. - Ran the helper under Node 24 as well: a TLS server returns
httpswith both127.0.0.1andlocalhostas host, a plain HTTP server returnshttp. bun run lint: pass (afterbun run lint:fix).bun run typecheckinapps/desktop: pass.bun testinapps/desktopwith Bun 1.4.3: 8870 pass, 0 fail.
No screenshot is attached: I did not capture this from a running dev app. No user-facing strings changed.
Checklist
- PR title follows conventional commits (
type(scope): subject) -
bun run lintandbun run typecheckpass (CI fails on lint warnings too) - "Allow edits from maintainers" is checked on fork PRs
- I have signed the CLA (the bot asks on your first PR)
Summary by cubic
Opens detected dev-server ports over https:// when the server speaks TLS, instead of always using http://localhost:<port>, which broke dev servers like Vite with a certificate.
- Probes the local port with a TLS handshake (self-signed certs accepted, 2 s timeout) at open time and falls back to
http://when the probe fails. - Applies to both the new sidebar and the legacy
MergedPortBadge, including forwarded remote ports. - The copy-URL action still uses
http://, since it is computed synchronously.
Summary by CodeRabbit
- New Features
- Local port links now detect whether a service supports HTTPS and use a secure URL when available.
- Port links opened from the dashboard or workspace sidebar use the detected scheme, whether opened in the app or externally.
- HTTP services and cases where scheme detection is unavailable continue to use the original URL.
- Bug Fixes
- Prevented repeated clicks from triggering overlapping port-opening attempts.