fix: handle ws upgrade smoothly

This commit is contained in:
Aarnav Tale
2025-03-11 22:39:49 -04:00
parent 134b38ceda
commit 251c16ca48
2 changed files with 5 additions and 14 deletions
+1 -6
View File
@@ -1,12 +1,7 @@
import WebSocket, { WebSocketServer } from 'ws';
import log from '~server/utils/log';
const server = new WebSocketServer({ noServer: true });
export function initWebsocket(authKey: string) {
if (authKey.length === 0) {
return;
}
export function initWebsocket(server: WebSocketServer, authKey: string) {
log.info('SRVX', 'Starting a WebSocket server for agent connections');
server.on('connection', (ws, req) => {
const tailnetID = req.headers['x-headplane-tailnet-id'];