Skip to content

feat: add root-path for opencode web#11858

Closed
DaehoYang wants to merge 16 commits intoanomalyco:devfrom
DaehoYang:dev
Closed

feat: add root-path for opencode web#11858
DaehoYang wants to merge 16 commits intoanomalyco:devfrom
DaehoYang:dev

Conversation

@DaehoYang
Copy link

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:
#7624
#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

Copilot AI and others added 16 commits February 1, 2026 22:24
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Add --root-path option for reverse proxy support
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
Improve rootPath implementation with fallback strategy and refactoring
Removed section on Deployment Modes from server documentation.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

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

Potential Duplicate Found:

Why it's related: PR #7625 appears to address the same feature (base path support for reverse proxy scenarios). The current PR #11858 is also adding root-path support for deploying OpenCode behind a reverse proxy. These likely overlap in functionality or one may be addressing the same issue from a different branch/approach. You may want to check if #7625 is already merged or if there's work duplication.

@DaehoYang
Copy link
Author

Duplicate

@DaehoYang DaehoYang closed this Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants