Skip to content

feat: support base path prefix for reverse proxy deployments #25776

@carsongee

Description

@carsongee

Problem

When running opencode web behind a reverse proxy that adds a path prefix (e.g. https://host/notebook-sessions/<id>/ports/4096/), the web UI breaks. The HTML is served at the prefixed URL but all assets use absolute root paths (/assets/index-xxx.js), so the browser fetches them from the host root and gets 404s.

Proposed solution

Add a --base-path CLI flag, OPENCODE_SERVER_BASE_PATH env var, and server.basePath config option. When set, the server injects a <base href="/the/prefix/"> tag into every HTML response. Browsers resolve all asset and navigation URLs relative to that base, so no rebuild is needed. The SolidJS Router is also given the base so client-side routing stays within the prefix.

Usage

# CLI flag
opencode web --base-path /notebook-sessions/abc123/ports/4096

# Env var
OPENCODE_SERVER_BASE_PATH=/notebook-sessions/abc123/ports/4096 opencode web

# opencode.json
{ "server": { "basePath": "/notebook-sessions/abc123/ports/4096" } }

Metadata

Metadata

Assignees

Labels

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions