From f91f785fa7c6794c5deeb9a1ee697840ece89a27 Mon Sep 17 00:00:00 2001 From: Devyash Saini Date: Fri, 29 May 2026 11:43:08 +0530 Subject: [PATCH] fix: derive HTTP URL from baseURL config instead of hardcoded localhost --- packages/scrawn/src/core/scrawn.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/scrawn/src/core/scrawn.ts b/packages/scrawn/src/core/scrawn.ts index 62f0a1a..f79011f 100644 --- a/packages/scrawn/src/core/scrawn.ts +++ b/packages/scrawn/src/core/scrawn.ts @@ -135,6 +135,9 @@ export class Scrawn< return this.apiKey; } + /** Base URL for the HTTP API (derived from baseURL config) */ + private httpUrl: string; + private sleep(ms: number): Promise { return new Promise((resolve) => setTimeout(resolve, ms)); } @@ -223,6 +226,7 @@ export class Scrawn< this.apiKey = config.apiKey; this.retryCount = config.retryCount ?? 2; + this.httpUrl = this.buildHttpUrl(config.baseURL); this.grpcClient = new GrpcClient(this.parseURLToTarget(config.baseURL), { secure: config.secure ?? true, credentials: config.credentials, @@ -245,6 +249,16 @@ export class Scrawn< : `${baseURL}:${ScrawnConfig.grpc.defaultPort}`; } + private buildHttpUrl(baseURL: string): string { + if (baseURL.includes("://")) { + const url = new URL(baseURL); + return `http://${url.hostname}:8070`; + } + + const host = baseURL.includes(":") ? baseURL.split(":")[0] : baseURL; + return `http://${host}:8070`; + } + /** * Create a type-safe tag reference. * @@ -1289,7 +1303,7 @@ export class Scrawn< async webhook(request: Request): Promise { if (!this.cachedPublicKey) { const response = await fetch( - "http://localhost:8070/api/v1/internals/webhook-endpoint/public-key", + `${this.httpUrl}/api/v1/internals/webhook-endpoint/public-key`, { headers: { Authorization: `Bearer ${this.apiKey}` } } ); if (!response.ok)