feat: support serving opencode from a subpath#25513
Open
ramonpaolo wants to merge 2 commits intoanomalyco:devfrom
Open
feat: support serving opencode from a subpath#25513ramonpaolo wants to merge 2 commits intoanomalyco:devfrom
ramonpaolo wants to merge 2 commits intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #23912: "feat: make opencode web embeddable in iframes at a subpath" Why it's related: This PR also addresses serving OpenCode from a subpath and handling mount paths. Both PRs are concerned with supporting non-root path deployment, though this one may have a specific focus on iframe embedding. Worth checking if #23912 is closed/merged and whether it covers the same scope as the current PR #25513. |
Contributor
|
Hey! Your PR title Please update it to start with one of:
Where See CONTRIBUTING.md for details. |
fca84c9 to
66c4164
Compare
3ff6dae to
ed7583b
Compare
04764af to
f71d546
Compare
f71d546 to
e8ace63
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #13847
Type of change
What does this PR do?
This adds native
basePathsupport for the OpenCode server and web UI so it can be served cleanly from a subpath such as/opencode/instead of assuming/.On the server side, requests can now arrive either with the configured prefix still present or already stripped by a reverse proxy, and both cases resolve to the same internal route tree. On the frontend side, the app shell now emits relative asset URLs, the HTML response exposes the effective mount path, and the browser uses that path when building API, SSE, WebSocket, and router URLs.
These changes work because they keep the existing API paths unchanged internally and treat the subpath as a transport/runtime concern at the server boundary and browser bootstrap boundary. That makes the legacy Hono backend, the experimental HttpApi backend, and the built app all agree on the same effective mount path.
How did you verify your code works?
npm exec -- bun test test/server/base-path.test.ts test/cli/network.test.ts test/server/httpapi-ui.test.tsinpackages/opencodenpm exec -- bun typecheckinpackages/opencodenpm exec -- bun test --preload ./happydom.ts ./src/utils/base-path.test.ts ./src/index-shell.test.ts ./src/vite-config.test.tsinpackages/appnpm exec -- bun typecheckinpackages/appnpm exec -- bun run buildinpackages/apppackages/app/dist/index.htmluses relative asset URLs such as./assets/...Screenshots / recordings
(See the URL on browser, that starts with "http://localhost/opencode")



Don't have visual UI changes; this PR changes mount-path, assets, routing and request behavior.
Checklist