Skip to content

feat: base path support (rebased from #7625)#12333

Closed
nick-the-nuke wants to merge 6 commits intoanomalyco:devfrom
nick-the-nuke:fix/base-path-v1.2.13
Closed

feat: base path support (rebased from #7625)#12333
nick-the-nuke wants to merge 6 commits intoanomalyco:devfrom
nick-the-nuke:fix/base-path-v1.2.13

Conversation

@nick-the-nuke
Copy link

Summary

  • Rebases base-path support from PR feat: base path support #7625 onto v1.2.13
  • Adds --base-path CLI option, OPENCODE_BASE_PATH env var, and server.basePath config
  • Rewrites HTML/JS/CSS responses at runtime to include the base path
  • Injects window.__OPENCODE_BASE_PATH__ into frontend for SolidJS Router compatibility

What this PR does

This is a rebase of @prokube's excellent work in #7625 onto the latest release tag (v1.2.13), resolving conflicts that arose from 275+ commits of drift.

Key features:

  • Configurable base path via CLI (--base-path), env var (OPENCODE_BASE_PATH), or config (server.basePath)
  • Runtime rewriting of proxied frontend assets to work under any URL prefix
  • History API wrapper to prepend base path to pushState/replaceState calls
  • Vite base path function patching for dynamic asset loading
  • Health endpoint now returns basePath for clients to discover the configuration

Testing

# Start server with base path
opencode web --base-path /myapp

# Or via environment variable
OPENCODE_BASE_PATH=/myapp opencode web

Access at http://localhost:4096/myapp/

Related

🤖 Generated with Claude Code

hsteude and others added 6 commits February 5, 2026 12:35
docs: improve comment explaining double mounting for reverse proxy support
- Add rewriting functions for HTML/JS/CSS to include basePath
- Update proxy handler to rewrite content when basePath is set
- Add basePath to health endpoint response
- Inject window.__OPENCODE_BASE_PATH__ into HTML responses
- Patch window.location.origin references in JS
- Rewrite asset URLs in CSS

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

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

Potential Duplicate Found:

The current PR #12333 is not a duplicate but rather a modernized rebase of the original work. If #7625 is still open, you may want to close it in favor of this newer version once #12333 is merged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants