Add --root-path option for reverse proxy support#1
Merged
Conversation
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>
Copilot
AI
changed the title
[WIP] Add --root-path option for reverse proxy support
Add --root-path option for reverse proxy support
Feb 1, 2026
Co-authored-by: DaehoYang <129835752+DaehoYang@users.noreply.github.com>
DaehoYang
approved these changes
Feb 1, 2026
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.
What does this PR do?
Adds
--root-pathCLI option toopencode webandopencode servefor deployment behind reverse proxies (e.g., Jupyter Server Proxy).Implementation:
CLI/Config: Added
rootPathstring option with validation (must start with/). Supports both CLI arg and config file (server.rootPath).Server: Uses Hono's
basePath()to prefix all routes including WebSocket upgrades:URL Construction: Uses URL constructor throughout for safe handling of special characters and encoding.
Display: Updated
webandservecommands to show correct URLs with path prefix.Usage:
Or via config:
{ "server": { "rootPath": "/proxy" } }Backward compatible—empty or omitted
rootPathmaintains existing behavior.How did you verify your code works?
Original prompt
Add --root-path option for reverse proxy support
Overview
Add
--root-pathoption toopencode webandopencode servecommands to support running behind reverse proxies like Jupyter Server Proxy. This option adds a base path prefix to all HTTP routes.Changes Required
1. CLI Option Definition
File:
packages/opencode/src/cli/network.tsAdd
rootPathoption to the options object:Update
resolveNetworkOptionsfunction to handle rootPath from config and CLI:2. Config Schema Update
File:
packages/opencode/src/config/config.tsAdd
rootPathfield to theServerschema (around line 850-860):3. Server Implementation
File:
packages/opencode/src/server/server.tsModify the
listenfunction signature to acceptrootPath:Apply
basePathwhen rootPath is provided (around line 567-580):Update the URL construction to include rootPath:
4. Web Command Update
File:
packages/opencode/src/cli/cmd/web.tsUpdate URL display to include rootPath (around line 47-76):
Apply the same logic for network IPs display.
5. Serve Command Update
File:
packages/opencode/src/cli/cmd/serve.tsUpdate console output (around line 14-16):
6. Documentation Updates
File:
packages/web/src/content/docs/cli.mdxAdd
--root-pathto bothwebandservecommand flags tables (around lines 365 and 461):File:
packages/web/src/content/docs/server.mdxUpdate options table (around line 13-27):
Add usage example:
File:
packages/web/src/content/docs/config.mdxUpdate server configuration section (around line 184-203):
Add example:
{ "$schema": "https://opencode.ai/config.json", "server": { "port": 4096, "hostname": "0.0.0.0", "rootPath": "/proxy" } }Testing Instructions
Manual Testing
Expected Behavior
/proxyprefixImplementation Notes
basePath()automatically handles all route prefixing including WebSocket upgrades_urlvariable should store the full URL including rootPath for correct behavior across the codebaseThis pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.