feat: add wss protocol detection in terminal WebSocket connection based on page origin scheme

This commit is contained in:
retoor 2025-10-09 23:23:18 +00:00
parent 0d2e5545fd
commit 73ac1c84f0

View File

@ -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 }}));
}};