From 73ac1c84f0881a1943245cd44b75d9cfdf8ea650 Mon Sep 17 00:00:00 2001 From: retoor Date: Thu, 9 Oct 2025 23:23:18 +0000 Subject: [PATCH] feat: add wss protocol detection in terminal WebSocket connection based on page origin scheme --- demo.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/demo.py b/demo.py index a426ea6..e3ec707 100755 --- a/demo.py +++ b/demo.py @@ -123,10 +123,9 @@ async def terminal(session_id: str): term.loadAddon(fitAddon); term.open(document.getElementById('terminal')); fitAddon.fit(); - - const ws = new WebSocket('ws://' + window.location.host + '/ws/{session_id}'); - - ws.onopen = () => {{ + const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; + const ws = new WebSocket(protocol + '//' + window.location.host + '/ws/{session_id}'); + ws.onopen = () => {{ const dims = {{ cols: term.cols, rows: term.rows }}; ws.send(JSON.stringify({{ type: 'resize', data: dims }})); }};