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 <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-13 15:13:45 -04:00
parent 9dc5938fa6
commit 10f3537b01
5 changed files with 5 additions and 5 deletions

View File

@ -20,7 +20,7 @@ import { RdpModule } from './rdp/rdp.module';
RdpModule,
ServeStaticModule.forRoot({
rootPath: join(__dirname, '..', '..', 'public'),
exclude: ['/api/(.*)'],
exclude: ['/api/(.*)', '/ws/(.*)'],
}),
],
})

View File

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

View File

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

View File

@ -10,7 +10,7 @@ export function useSftp(sessionId: Ref<string | null>) {
const transfers = ref<any[]>([])
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) => {

View File

@ -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 = () => {