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) 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 }) =>