From 59aab1ddf7f5ae4a57331c0114056e4df25b2458 Mon Sep 17 00:00:00 2001 From: Josh Brooks Date: Thu, 5 Feb 2026 20:04:44 +0000 Subject: [PATCH] feat(opencode): add OPENCODE_APP_URL for custom web app proxy Add environment variable to proxy the web UI to a custom URL instead of app.opencode.ai. This enables enterprises to host the web UI internally and have users run the local server pointing to the internal instance. --- packages/opencode/src/flag/flag.ts | 1 + packages/opencode/src/server/server.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/opencode/src/flag/flag.ts b/packages/opencode/src/flag/flag.ts index f1688a1b40a..85e00e6a768 100644 --- a/packages/opencode/src/flag/flag.ts +++ b/packages/opencode/src/flag/flag.ts @@ -37,6 +37,7 @@ export namespace Flag { export const OPENCODE_SERVER_PASSWORD = process.env["OPENCODE_SERVER_PASSWORD"] export const OPENCODE_SERVER_USERNAME = process.env["OPENCODE_SERVER_USERNAME"] export const OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL") + export const OPENCODE_APP_URL = process.env["OPENCODE_APP_URL"] // Experimental export const OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL") diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index 55bcf2dfce1..ad8b0efa5a5 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -557,11 +557,13 @@ export namespace Server { .all("/*", async (c) => { const path = c.req.path - const response = await proxy(`https://app.opencode.ai${path}`, { + // Proxy to configured app URL or default to app.opencode.ai + const appUrl = Flag.OPENCODE_APP_URL ? new URL(Flag.OPENCODE_APP_URL) : new URL("https://app.opencode.ai") + const response = await proxy(`${appUrl.origin}${path}`, { ...c.req, headers: { ...c.req.raw.headers, - host: "app.opencode.ai", + host: appUrl.host, }, }) response.headers.set(