Skip to content

feat(server): runtime base path support for reverse proxy deployments#28326

Open
fabiovincenzi wants to merge 8 commits into
anomalyco:devfrom
fabiovincenzi:feat/base-path-support
Open

feat(server): runtime base path support for reverse proxy deployments#28326
fabiovincenzi wants to merge 8 commits into
anomalyco:devfrom
fabiovincenzi:feat/base-path-support

Conversation

@fabiovincenzi
Copy link
Copy Markdown

@fabiovincenzi fabiovincenzi commented May 19, 2026

Issue for this PR

Closes #7624

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a --base-path flag (also server.basePath in config) so opencode web works behind a reverse proxy at a prefix like platform.com/opencode/.
The server strips the prefix before routing, redirects /opencode/opencode/, and returns 404 for anything outside the prefix.
The UI picks up the base path via an injected global so the SolidJS router and API calls use the right URLs.
Vite base changed to "./" for relative chunk imports.
Supersedes #7625, #18209, #25513, #23912.

How did you verify your code works?

Built with bun run --cwd packages/opencode build -- --single, ran opencode web --base-path /opencode.
UI loads, assets resolve, API works under prefix, 404 outside it, 301 redirect without trailing slash, no breakage without the flag.

Screenshots / recordings

N/A — no visual changes, only routing behavior.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

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

Related PRs Found

This PR (28326) supersedes several earlier attempts at solving the same problem, as noted in the description. Here are the related PRs:

  1. feat: base path support #7625 - "feat: base path support"
  2. feat: support serving opencode from a subpath #25513 - "feat: support serving opencode from a subpath"
  3. feat: make opencode web embeddable in iframes at a subpath #23912 - "feat: make opencode web embeddable in iframes at a subpath"
  4. feat: App - Support setting base URL during build #18209 - "feat: App - Support setting base URL during build"

Why they're related:
All of these PRs attempt to solve the same problem of supporting base path/subpath deployment. According to the PR description, PR #28326 is the comprehensive solution that supersedes the earlier attempts because:

This PR consolidates all the learnings into a complete implementation with both CLI flag support, server-side request interception, HTML injection, and frontend SolidJS router integration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Base path / prefix routing support

1 participant