Hi there,
I'm looking to connect to an external WebSocket. However, the WebSocket requires that certain headers be present.
I see that the WebSocket constructor accepts WebSocket.ClientOptions as a second or third argument:
declare class WebSocket extends EventEmitter {
// ...
constructor(address: string | URL, options?: WebSocket.ClientOptions | ClientRequestArgs);
constructor(
address: string | URL,
protocols?: string | string[],
options?: WebSocket.ClientOptions | ClientRequestArgs,
);
interface ClientOptions extends SecureContextOptions {
// ...
headers?: { [key: string]: string } | undefined;
However, I can't seem to use WebSocket.ClientOptions with a new WebSocket at all — see attached.
Am I missing something?
I can do this with ws, but would prefer not to.