Skip to content

Commit 81c05a1

Browse files
committed
use wss: by default, only use ws: for local development
1 parent 70dfc67 commit 81c05a1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/hypergraph-react/src/HypergraphAppContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ export function HypergraphAppProvider({
299299

300300
const syncServerUrl = new URL(syncServerUri);
301301
const syncServerWsUrl = new URL(`/?token=${identity.sessionToken}`, syncServerUrl.toString());
302-
syncServerWsUrl.protocol = 'ws:';
302+
303+
// Use 'wss:' by default, only use 'ws:' for local development
304+
const isLocalDev = syncServerUrl.hostname === 'localhost' || syncServerUrl.hostname === '127.0.0.1';
305+
syncServerWsUrl.protocol = isLocalDev ? 'ws:' : 'wss:';
306+
303307
const syncServerWsUrlString = syncServerWsUrl.toString();
304308

305309
const websocketConnection = new WebSocket(syncServerWsUrlString);

0 commit comments

Comments
 (0)