INNER CODE UNIT · TypeScript
protocols
im4codes/imcodes · server/src/index.ts:605
const protocols = protocolHeader ? protocolHeader.split(',').map((p) => p.trim()).filter(Boolean) : [];
// 7. Generate wsId (32 hex chars, consistent with requestId format)
const wsId = crypto.randomUUID().replace(/-/g, '');
logger.info({
serverId,
previewId,
wsId,
path: upstreamPathWithQuery,
protocols,
}, 'Preview WS tunnel upgrade');
// 8. Defer the browser handshake until the daemon reports the upstream-
// negotiated subprotocol (run 8a975732-23a P1.5.1), then complete the
// handshake echoing exactly that protocol so the browser's
// `WebSocket.protocol` matches the upstream end-to-end. The `ws` library
// echoes whatever `Sec-WebSocket-Protocol` the request carries, so we