Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

366 B
Raw Blame
import type { IncomingMessage } from 'node:http';

export function collabUrlFromRequestHeaders(headers: IncomingMessage['headers']): string | null {
  const host = headers.host;
  if (!host) return null;
  const fwd = headers['x-forwarded-proto'];
  const proto = Array.isArray(fwd) ? fwd[0] : fwd;
  return `${proto === 'https' ? 'wss' : 'ws'}://${host}/collab`;
}