Skip to content

feat: add OPENCODE_APP_URL for custom web app proxy#12446

Open
jobrk wants to merge 1 commit intoanomalyco:devfrom
jobrk:feat/self-hosted-web-app
Open

feat: add OPENCODE_APP_URL for custom web app proxy#12446
jobrk wants to merge 1 commit intoanomalyco:devfrom
jobrk:feat/self-hosted-web-app

Conversation

@jobrk
Copy link

@jobrk jobrk commented Feb 6, 2026

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.

The code changes are simple and self explanatory

  • OPENCODE_APP_URL overrides the default https://app.opencode.ai base for the web UI proxy
  • The full URL pathname is now preserved, so hosting on a subpath (e.g. GitHub Pages at https://user.github.io/opencode) works correctly

Fixes #12445

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found two potentially related PRs:

  1. feat(opencode): add HTTP/HTTPS proxy support (feat(opencode): add HTTP/HTTPS proxy support #10856)

  2. feat: base path support (feat: base path support #7625)

    • feat: base path support #7625
    • Related because it handles custom URL path configuration, which is similar in intent to allowing custom web app proxying

These are contextually related to URL/proxy customization, though they may address different aspects of the feature. PR #12446 specifically focuses on proxying the web UI to a custom URL via an environment variable, which appears to be a more specific use case than the broader proxy support in #10856.

@jobrk jobrk force-pushed the feat/self-hosted-web-app branch from f296208 to 98db1c2 Compare February 21, 2026 08:56
@jobrk jobrk requested a review from kikuchan February 26, 2026 10:46
@jobrk
Copy link
Author

jobrk commented Mar 5, 2026

@kikuchan hey this has been up for a while, could I help with anything to get this merged ?

@kikuchan
Copy link
Contributor

kikuchan commented Mar 6, 2026

I'm sorry, I think I can't. I'm just a developper, not a member of OC. besides, I'm not able to press the "approve" button on the screen...
image

I am a person who also want this PR is merged...

@kikuchan
Copy link
Contributor

The subpath doesn't work for me yet...

Could you change it like this please?:

diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts
index ad8b0efa5..9cf0cfeda 100644
--- a/packages/opencode/src/server/server.ts
+++ b/packages/opencode/src/server/server.ts
@@ -559,7 +559,8 @@ export namespace Server {

         // 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}`, {
+        appUrl.pathname = appUrl.pathname.replace(/\/$/, '') + path;
+        const response = await proxy(appUrl, {
           ...c.req,
           headers: {
             ...c.req.raw.headers,

because .origin doesn't contain a subpath.

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.
@jobrk jobrk force-pushed the feat/self-hosted-web-app branch from 6688e5e to 59aab1d Compare March 16, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Support for custom web app proxy URL in firewalled environments

2 participants