Skip to content

Commit 6688e5e

Browse files
author
Josh Brooks
committed
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 8024166 commit 6688e5e

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
@@ -37,6 +37,7 @@ export namespace Flag {
3737
export const OPENCODE_SERVER_PASSWORD = process.env["OPENCODE_SERVER_PASSWORD"]
3838
export const OPENCODE_SERVER_USERNAME = process.env["OPENCODE_SERVER_USERNAME"]
3939
export const OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL")
40+
export const OPENCODE_APP_URL = process.env["OPENCODE_APP_URL"]
4041

4142
// Experimental
4243
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
@@ -555,11 +555,13 @@ export namespace Server {
555555
.all("/*", async (c) => {
556556
const path = c.req.path
557557

558-
const response = await proxy(`https://app.opencode.ai${path}`, {
558+
// Proxy to configured app URL or default to app.opencode.ai
559+
const appUrl = Flag.OPENCODE_APP_URL ? new URL(Flag.OPENCODE_APP_URL) : new URL("https://app.opencode.ai")
560+
const response = await proxy(`${appUrl.origin}${path}`, {
559561
...c.req,
560562
headers: {
561563
...c.req.raw.headers,
562-
host: "app.opencode.ai",
564+
host: appUrl.host,
563565
},
564566
})
565567
response.headers.set(

0 commit comments

Comments
 (0)