From 9d9ea37d61b2ed808e34f4ff55349106129d7edb Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Wed, 1 Jul 2026 16:06:52 -0700 Subject: [PATCH 1/2] feat: make backend worker API URL configurable via WORKER_API_URL The backend worker API host/port was hardcoded to localhost:3060 in both the worker (api.ts) and the web app that calls it (workerApi/actions.ts). Add a WORKER_API_URL env var (default http://localhost:3060): the web app dials it, and the worker derives its listen port from it, so the two can't drift. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/backend/src/api.ts | 4 +++- packages/shared/src/env.server.ts | 2 ++ packages/web/src/features/workerApi/actions.ts | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/api.ts b/packages/backend/src/api.ts index b9111722f..3be070349 100644 --- a/packages/backend/src/api.ts +++ b/packages/backend/src/api.ts @@ -14,7 +14,9 @@ import { SINGLE_TENANT_ORG_ID } from './constants.js'; import z from 'zod'; const logger = createLogger('api'); -const PORT = 3060; + +const workerApiUrl = new URL(env.WORKER_API_URL); +const PORT = Number(workerApiUrl.port) || (workerApiUrl.protocol === "https:" ? 443 : 80); export class Api { private server: http.Server; diff --git a/packages/shared/src/env.server.ts b/packages/shared/src/env.server.ts index b832bce4f..1f96a188d 100644 --- a/packages/shared/src/env.server.ts +++ b/packages/shared/src/env.server.ts @@ -172,6 +172,8 @@ const options = { // Zoekt ZOEKT_WEBSERVER_URL: z.string().url().default("http://localhost:6070"), + WORKER_API_URL: z.string().url().default("http://localhost:3060"), + // Auth AUTH_SECRET: z.string(), AUTH_URL: z.string().url(), diff --git a/packages/web/src/features/workerApi/actions.ts b/packages/web/src/features/workerApi/actions.ts index dae456197..9e681d9de 100644 --- a/packages/web/src/features/workerApi/actions.ts +++ b/packages/web/src/features/workerApi/actions.ts @@ -5,9 +5,10 @@ import { unexpectedError } from "@/lib/serviceError"; import { withAuth, withOptionalAuth } from "@/middleware/withAuth"; import { withMinimumOrgRole } from "@/middleware/withMinimumOrgRole"; import { OrgRole } from "@sourcebot/db"; +import { env } from "@sourcebot/shared"; import z from "zod"; -const WORKER_API_URL = 'http://localhost:3060'; +const WORKER_API_URL = env.WORKER_API_URL; export const syncConnection = async (connectionId: number) => sew(() => withAuth(({ role }) => From 8ca2722adcf087161470e80c62eab409764815e2 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Wed, 1 Jul 2026 16:07:11 -0700 Subject: [PATCH 2/2] docs: add CHANGELOG entry for #1409 Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a422ee26..7b89a5c92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - [EE] Improved Ask Sourcebot prompt caching by splitting static and dynamic prompt sections and advancing cache breakpoints after every agent step instead of only after each message. [#1366](https://github.com/sourcebot-dev/sourcebot/pull/1366) - Refactored Ask Sourcebot user message text extraction into a shared helper that robustly handles non-text message parts. [#1371](https://github.com/sourcebot-dev/sourcebot/pull/1371) +- Made the backend worker API address configurable via the `WORKER_API_URL` environment variable (default `http://localhost:3060`) instead of being hardcoded. [#1409](https://github.com/sourcebot-dev/sourcebot/pull/1409) ### Added - Added per-step token cost tracking and estimated tool call token usage to Ask Sourcebot chat history. [#1353](https://github.com/sourcebot-dev/sourcebot/pull/1353)