Skip to content

feat: add base path support for reverse proxy deployments#25777

Closed
carsongee wants to merge 1 commit intoanomalyco:devfrom
datarobot-forks:feat/server-base-path
Closed

feat: add base path support for reverse proxy deployments#25777
carsongee wants to merge 1 commit intoanomalyco:devfrom
datarobot-forks:feat/server-base-path

Conversation

@carsongee
Copy link
Copy Markdown

Closes #25776

What

Adds a base path option so opencode web works correctly when served behind a reverse proxy that adds a path prefix.

Three ways to configure it:

  • --base-path /my/prefix CLI flag
  • OPENCODE_SERVER_BASE_PATH=/my/prefix env var
  • server.basePath in opencode.json

Why

Asset URLs in the built HTML use root-relative paths (/assets/index-xxx.js). Behind a path-prefixed proxy the browser resolves them against the host root, not the proxy prefix, causing 404s for all JS/CSS.

How it works

When basePath is set, the server injects <base href="/the/prefix/"> into every HTML response (both embedded and proxied). Browsers then resolve all asset and navigation URLs relative to that base — no rebuild required. The SolidJS Router reads the <base> element at boot and uses its pathname as its base prop so client-side routing stays within the prefix.

Verification

Start with a prefix:

opencode web --port 4096 --base-path /notebook-sessions/abc/ports/4096

Confirm curl -s http://localhost:4096/ | grep '<base' returns <base href="/notebook-sessions/abc/ports/4096/">, and that all assets load when accessing via the proxy URL.

Adds OPENCODE_SERVER_BASE_PATH env var, --base-path CLI flag, and
server.basePath config option. When set, injects a <base href> tag
into HTML responses so asset references resolve correctly when
opencode web is served behind a path-prefixed reverse proxy. The
SolidJS Router is also given the base path so client-side navigation
stays within the prefix.
@carsongee carsongee requested a review from adamdotdevin as a code owner May 4, 2026 23:00
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

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

Potential Duplicates Found

There are existing PRs addressing similar functionality:

  1. PR feat: support serving opencode from a subpath #25513 - "feat: support serving opencode from a subpath"

  2. PR feat: make opencode web embeddable in iframes at a subpath #23912 - "feat: make opencode web embeddable in iframes at a subpath"

  3. PR feat: base path support #7625 - "feat: base path support"

Recommendation: Check PR #25513 and #23912 to see if they address the same reverse proxy path prefix issue, particularly around asset URL resolution and the <base href> injection approach.

@carsongee
Copy link
Copy Markdown
Author

Closing in favor of the existing PR addressing #7624.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support base path prefix for reverse proxy deployments

1 participant