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:
parent
9dc5938fa6
commit
10f3537b01
@ -20,7 +20,7 @@ import { RdpModule } from './rdp/rdp.module';
|
||||
RdpModule,
|
||||
ServeStaticModule.forRoot({
|
||||
rootPath: join(__dirname, '..', '..', 'public'),
|
||||
exclude: ['/api/(.*)'],
|
||||
exclude: ['/api/(.*)', '/ws/(.*)'],
|
||||
}),
|
||||
],
|
||||
})
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) => {
|
||||
|
||||
@ -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 = () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user