Skip to content

Missing option to provide HTTP headers (e.g. for authentication) #39

@djakielski

Description

@djakielski

Currently, the WebsocketClientBuilder in websocket-ts does not expose any way to inject custom HTTP headers when establishing the WebSocket handshake. This makes it impossible to use bearer tokens or other header-based authentication schemes with the library out of the box.

Many API Gateway or proxy setups require clients to present an Authorization header (e.g. Bearer ) at handshake time. Without the ability to set headers, users must resort to embedding tokens in query parameters (which is less secure) or reimplementing the underlying connection logic themselves.

const client = new WebsocketClientBuilder()
  .url("wss://example.com/socket")
  .build();

// No API to add headers:
// client.withHeader("Authorization", `Bearer ${token}`)  ← not supported

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions