Skip to content

Commit bf251a6

Browse files
committed
feat: Use BASE_URL for WebSocket connection paths in the shell component.
1 parent 407d0af commit bf251a6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/components/Shell.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { WebglAddon } from '@xterm/addon-webgl';
55
import { WebLinksAddon } from '@xterm/addon-web-links';
66
import '@xterm/xterm/css/xterm.css';
77

8+
import { BASE_URL } from '../utils/api';
9+
810
const xtermStyles = `
911
.xterm .xterm-screen {
1012
outline: none !important;
@@ -58,7 +60,7 @@ function Shell({ selectedProject, selectedSession, initialCommand, isPlainShell
5860

5961
if (isPlatform) {
6062
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
61-
wsUrl = `${protocol}//${window.location.host}/shell`;
63+
wsUrl = `${protocol}//${window.location.host}${BASE_URL}/shell`;
6264
} else {
6365
const token = localStorage.getItem('auth-token');
6466
if (!token) {
@@ -67,7 +69,8 @@ function Shell({ selectedProject, selectedSession, initialCommand, isPlainShell
6769
}
6870

6971
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
70-
wsUrl = `${protocol}//${window.location.host}/shell?token=${encodeURIComponent(token)}`;
72+
const queryParams = (token && !skipAuth) ? `?token=${encodeURIComponent(token)}` : '';
73+
wsUrl = `${protocol}//${window.location.host}${BASE_URL}/shell${queryParams}`;
7174
}
7275

7376
ws.current = new WebSocket(wsUrl);
@@ -296,7 +299,7 @@ function Shell({ selectedProject, selectedSession, initialCommand, isPlainShell
296299
data: text
297300
}));
298301
}
299-
}).catch(() => {});
302+
}).catch(() => { });
300303
return false;
301304
}
302305

0 commit comments

Comments
 (0)