From 10f3537b0117f26d096f5ad65b120a79361ab3ba Mon Sep 17 00:00:00 2001 From: Vantz Stockwell Date: Fri, 13 Mar 2026 15:13:45 -0400 Subject: [PATCH] fix: move WebSocket paths under /api/ prefix to work through NPM proxy NPM forwards /api/* correctly but silently drops WebSocket upgrades on /ws/* despite toggle being enabled and custom nginx config. Moving gateways to /api/ws/terminal and /api/ws/sftp so they ride the same proxy rules that already work for REST endpoints. Co-Authored-By: Claude Opus 4.6 --- backend/src/app.module.ts | 2 +- backend/src/terminal/sftp.gateway.ts | 2 +- backend/src/terminal/terminal.gateway.ts | 2 +- frontend/composables/useSftp.ts | 2 +- frontend/composables/useTerminal.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index 569591a..4143067 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -20,7 +20,7 @@ import { RdpModule } from './rdp/rdp.module'; RdpModule, ServeStaticModule.forRoot({ rootPath: join(__dirname, '..', '..', 'public'), - exclude: ['/api/(.*)'], + exclude: ['/api/(.*)', '/ws/(.*)'], }), ], }) diff --git a/backend/src/terminal/sftp.gateway.ts b/backend/src/terminal/sftp.gateway.ts index 7384845..c1b8e60 100644 --- a/backend/src/terminal/sftp.gateway.ts +++ b/backend/src/terminal/sftp.gateway.ts @@ -6,7 +6,7 @@ import { SshConnectionService } from './ssh-connection.service'; const MAX_EDIT_SIZE = 5 * 1024 * 1024; // 5MB -@WebSocketGateway({ path: '/ws/sftp' }) +@WebSocketGateway({ path: '/api/ws/sftp' }) export class SftpGateway implements OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() server: Server; private readonly logger = new Logger(SftpGateway.name); diff --git a/backend/src/terminal/terminal.gateway.ts b/backend/src/terminal/terminal.gateway.ts index f2e8a7b..4642ff2 100644 --- a/backend/src/terminal/terminal.gateway.ts +++ b/backend/src/terminal/terminal.gateway.ts @@ -4,7 +4,7 @@ import { Server } from 'ws'; import { WsAuthGuard } from '../auth/ws-auth.guard'; import { SshConnectionService } from './ssh-connection.service'; -@WebSocketGateway({ path: '/ws/terminal' }) +@WebSocketGateway({ path: '/api/ws/terminal' }) export class TerminalGateway implements OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() server: Server; private readonly logger = new Logger(TerminalGateway.name); diff --git a/frontend/composables/useSftp.ts b/frontend/composables/useSftp.ts index 9bdbdca..0d2f038 100644 --- a/frontend/composables/useSftp.ts +++ b/frontend/composables/useSftp.ts @@ -10,7 +10,7 @@ export function useSftp(sessionId: Ref) { const transfers = ref([]) function connect() { - const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws/sftp?token=${auth.token}` + const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/api/ws/sftp?token=${auth.token}` ws = new WebSocket(wsUrl) ws.onmessage = (event) => { diff --git a/frontend/composables/useTerminal.ts b/frontend/composables/useTerminal.ts index f50d98c..c3ad837 100644 --- a/frontend/composables/useTerminal.ts +++ b/frontend/composables/useTerminal.ts @@ -56,7 +56,7 @@ export function useTerminal() { } function connectToHost(hostId: number, hostName: string, protocol: 'ssh', color: string | null, pendingSessionId: string, term: Terminal, fitAddon: FitAddon) { - const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws/terminal?token=${auth.token}` + const wsUrl = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/api/ws/terminal?token=${auth.token}` ws = new WebSocket(wsUrl) ws.onopen = () => {