type
WebSocketOptionsProxy
type WebSocketOptionsProxy =
- proxy?: string | URL | { headers: OutgoingHttpHeaders | Headers; url: string | URL }
HTTP proxy to use for the WebSocket connection.
Can be a string URL, a URL instance, or an object with
urland optionalheaders.// String format const ws = new WebSocket("wss://example.com", { proxy: "http://proxy.example.com:8080" }); // With credentials const ws = new WebSocket("wss://example.com", { proxy: "http://user:pass@proxy.example.com:8080" }); // Object format with custom headers const ws = new WebSocket("wss://example.com", { proxy: { url: "http://proxy.example.com:8080", headers: { "Proxy-Authorization": "Bearer token" } } });