mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 05:30:46 +08:00
fix(webcrt): install websockets and connect WS to API in Vite dev
Uvicorn had no WebSocket implementation without the websockets package, causing browser websocket_error. Also bypass flaky Vite WS proxy by targeting :8890 in local UI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
183cb7eec9
commit
1f2e028337
5 changed files with 23 additions and 3 deletions
|
|
@ -113,10 +113,14 @@ export function WebTerminal({ wsUrl, title, onStatus, onReady }: Props) {
|
|||
ws.onerror = () => {
|
||||
onStatusRef.current?.("error", "websocket_error");
|
||||
term.writeln("\r\n\x1b[31m[websocket error]\x1b[0m");
|
||||
term.writeln("\x1b[33mHint: ensure API has package 'websockets' and is restarted; Vite UI should reach ws://127.0.0.1:8890\x1b[0m");
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
onStatusRef.current?.("closed", "websocket_closed");
|
||||
ws.onclose = (ev) => {
|
||||
onStatusRef.current?.("closed", `websocket_closed:${ev.code}`);
|
||||
if (!ev.wasClean) {
|
||||
term.writeln(`\r\n\x1b[33m[websocket closed code=${ev.code}]\x1b[0m`);
|
||||
}
|
||||
};
|
||||
|
||||
const dataDisposable = term.onData((data) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue