[PR #11858] feat: add root-path for opencode web #13959

Closed
opened 2026-02-16 18:18:47 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11858

State: closed
Merged: No


Summary

This pull request adds robust support for deploying the OpenCode web app behind a reverse proxy at a configurable base path (rootPath). It introduces a new CLI/config option for rootPath, ensures all URLs and static assets are correctly resolved relative to this path, and injects the configuration into the frontend.

related issues:
https://github.com/anomalyco/opencode/issues/7624
https://github.com/anomalyco/opencode/issues/6336
and else...

Changes

Reverse Proxy & Root Path Support

  • Added a new rootPath option to CLI (--root-path), config, and network options, allowing the app to be served at a custom base path for reverse proxy scenarios.
  • Server startup now requires a local build when rootPath is set, enforcing this with a clear error message if the build is missing.
  • All URLs (including those shown in CLI output and used by the frontend) are normalized to respect the rootPath, avoiding duplicate slashes and ensuring correct asset resolution.

Frontend Integration

  • Injects the rootPath into the frontend via a <base> tag, a script setting window.__OPENCODE__.rootPath, and a data-root-path attribute on the root div, using the new injectRootPath utility.
  • Frontend router and API base URL logic updated to use the injected rootPath, ensuring proper navigation and resource loading.
  • Refactored server code to centralize static file serving and index.html handling, with clear separation between local and remote fallback modes.

Testing

git clone https://github.com/DaehoYang/opencode
cd opencode
bun install
cd packages/app
bun run build
cd ../..
bun run dev web --root-path /proxy
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11858 **State:** closed **Merged:** No --- ### Summary This pull request adds robust support for deploying the OpenCode web app behind a reverse proxy at a configurable base path (`rootPath`). It introduces a new CLI/config option for `rootPath`, ensures all URLs and static assets are correctly resolved relative to this path, and injects the configuration into the frontend. related issues: https://github.com/anomalyco/opencode/issues/7624 https://github.com/anomalyco/opencode/issues/6336 and else... ### Changes **Reverse Proxy & Root Path Support** * Added a new `rootPath` option to CLI (`--root-path`), config, and network options, allowing the app to be served at a custom base path for reverse proxy scenarios. * Server startup now requires a local build when `rootPath` is set, enforcing this with a clear error message if the build is missing. * All URLs (including those shown in CLI output and used by the frontend) are normalized to respect the `rootPath`, avoiding duplicate slashes and ensuring correct asset resolution. **Frontend Integration** * Injects the `rootPath` into the frontend via a `<base>` tag, a script setting `window.__OPENCODE__.rootPath`, and a `data-root-path` attribute on the root div, using the new `injectRootPath` utility. * Frontend router and API base URL logic updated to use the injected `rootPath`, ensuring proper navigation and resource loading. * Refactored server code to centralize static file serving and index.html handling, with clear separation between local and remote fallback modes. ### Testing ```bash git clone https://github.com/DaehoYang/opencode cd opencode bun install cd packages/app bun run build cd ../.. bun run dev web --root-path /proxy ```
yindo added the pull-request label 2026-02-16 18:18:47 -05:00
yindo closed this issue 2026-02-16 18:18:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13959