Skip to content

fix(client): use wss:// when served over HTTPS#96

Open
acooks wants to merge 1 commit into
masterfrom
fix/websocket-https-scheme
Open

fix(client): use wss:// when served over HTTPS#96
acooks wants to merge 1 commit into
masterfrom
fix/websocket-https-scheme

Conversation

@acooks

@acooks acooks commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Problem

The WebSocket URI scheme is hardcoded to ws:// in html5-client/src/js/jittertrap.js:

const wsUri = "ws://" + document.domain + ":" + location.port;

When the client is served over HTTPS, the browser blocks this as mixed content (an insecure ws:// socket from a secure page), so the live-data websocket never connects.

Fix

Derive the scheme from location.protocol, and only append a port when one is present:

const wsUri = (location.protocol === "https:" ? "wss://" : "ws://")
              + document.domain
              + (location.port ? ":" + location.port : "");
  • wss:// on HTTPS pages, ws:// otherwise.
  • Omitting an empty port lets it work behind a TLS-terminating reverse proxy on the default 443 (where location.port is "").

Testing

Verified on a live deployment behind nginx (TLS termination → proxy_pass to jt-server): the page loads over HTTPS and the websocket upgrade completes (101 Switching Protocols over wss://). Plain-HTTP behaviour is unchanged.

🤖 Generated with Claude Code

The WebSocket URI scheme was hardcoded to ws://, so loading the client
over HTTPS triggered a mixed-content error and the browser blocked the
live-data connection (it never opened).

Derive the scheme from location.protocol (wss:// on HTTPS, ws://
otherwise) and only append a port when one is present, so it also works
behind a TLS-terminating reverse proxy on the default port 443.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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