Skip to content

fix(events): use ws:// when API host is http:// (dev mode support)#201

Merged
hsablonniere merged 1 commit intoCleverCloud:masterfrom
waxzce:fix/ws-protocol-dev-mode
Apr 1, 2026
Merged

fix(events): use ws:// when API host is http:// (dev mode support)#201
hsablonniere merged 1 commit intoCleverCloud:masterfrom
waxzce:fix/ws-protocol-dev-mode

Conversation

@waxzce
Copy link
Copy Markdown
Member

@waxzce waxzce commented Mar 25, 2026

Problem

EventsStream always forces wss: protocol for the WebSocket connection, even when the API host uses http://. This breaks local development environments where TLS is not configured.

Fix

-        urlObj.protocol = 'wss:';
+        urlObj.protocol = urlObj.protocol === 'http:' ? 'ws:' : 'wss:';

Use ws: when the API host protocol is http:, wss: otherwise. This is backward-compatible — production environments using https:// will continue to use wss: as before.

Context

Discovered during the Clever Cloud Rust monolith migration (clevercloud-rust-rebuilt). The dev-runner serves the full API on HTTP without TLS, and Console3's EventsStream fails silently because it tries wss://localhost:8080 which has no TLS certificate.

EventsStream always forced wss: protocol for WebSocket connections,
breaking local development environments without TLS.

Fix: use ws: when API host protocol is http:, wss: otherwise.
Backward-compatible — production https:// continues to use wss:.

Context: discovered during Clever Cloud Rust monolith migration.
Dev-runner serves on HTTP, Console3 EventsStream failed silently
trying wss://localhost:8080 with no TLS certificate.
Copy link
Copy Markdown
Member

@hsablonniere hsablonniere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first reaction was "you should be able to have secured WS, even locally" but I guess this is OK to merge it if it helps.

@hsablonniere hsablonniere merged commit df2ab72 into CleverCloud:master Apr 1, 2026
4 checks passed
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.

2 participants