Skip to content

Commit 98db1c2

Browse files
Josh Brooksjobrk
authored andcommitted
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.
1 parent 206d81e commit 98db1c2

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

packages/opencode/src/flag/flag.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export namespace Flag {
3131
export const OPENCODE_SERVER_PASSWORD = process.env["OPENCODE_SERVER_PASSWORD"]
3232
export const OPENCODE_SERVER_USERNAME = process.env["OPENCODE_SERVER_USERNAME"]
3333
export const OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL")
34+
export const OPENCODE_APP_URL = process.env["OPENCODE_APP_URL"]
3435

3536
// Experimental
3637
export const OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL")

packages/opencode/src/server/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,11 +543,13 @@ export namespace Server {
543543
.all("/*", async (c) => {
544544
const path = c.req.path
545545

546-
const response = await proxy(`https://app.opencode.ai${path}`, {
546+
// Proxy to configured app URL or default to app.opencode.ai
547+
const appUrl = Flag.OPENCODE_APP_URL ? new URL(Flag.OPENCODE_APP_URL) : new URL("https://app.opencode.ai")
548+
const response = await proxy(`${appUrl.origin}${path}`, {
547549
...c.req,
548550
headers: {
549551
...c.req.raw.headers,
550-
host: "app.opencode.ai",
552+
host: appUrl.host,
551553
},
552554
})
553555
response.headers.set(

0 commit comments

Comments
 (0)