diff --git a/src/core/http.ts b/src/core/http.ts index 53325f7..6529bde 100644 --- a/src/core/http.ts +++ b/src/core/http.ts @@ -82,6 +82,10 @@ export class HttpClient { return this.jwt || this.apiKey; } + getApiKey(): string | undefined { + return this.apiKey; + } + async request( method: "GET" | "POST" | "PUT" | "DELETE", path: string, @@ -105,6 +109,10 @@ export class HttpClient { ...options.headers, }; + if (path.startsWith("/v1/pubsub/publish")) { + console.log("publish headers", headers); + } + // Debug: Log headers being sent if ( typeof console !== "undefined" && diff --git a/src/pubsub/client.ts b/src/pubsub/client.ts index 912cfc7..7cffd82 100644 --- a/src/pubsub/client.ts +++ b/src/pubsub/client.ts @@ -119,18 +119,19 @@ export class PubSubClient { } = {} ): Promise { // Build WebSocket URL for this topic - const wsUrl = new URL(this.wsConfig.wsURL || "ws://localhost:6001"); + const wsUrl = new URL(this.wsConfig.wsURL || "ws://127.0.0.1:6001"); wsUrl.pathname = "/v1/pubsub/ws"; wsUrl.searchParams.set("topic", topic); + const authToken = this.httpClient.getApiKey() ?? this.httpClient.getToken(); + // Create WebSocket client const wsClient = new WSClient({ ...this.wsConfig, wsURL: wsUrl.toString(), - authToken: this.httpClient.getToken(), + authToken, }); - console.log("[PubSubClient] Connecting to topic:", topic); await wsClient.connect(); // Create subscription wrapper