Pproxy
Bun

property

WebSocketOptionsProxy.proxy

proxy?: string | { headers: OutgoingHttpHeaders | Headers; url: string }

HTTP proxy to use for the WebSocket connection.

Can be a string URL or an object with url and optional headers.

// 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"
    }
  }
});