feat(server): runtime base path support for reverse proxy deployments - #28326
feat(server): runtime base path support for reverse proxy deployments#28326fabiovincenzi wants to merge 27 commits into
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Related PRs FoundThis PR (28326) supersedes several earlier attempts at solving the same problem, as noted in the description. Here are the related PRs:
Why they're related:
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. |
19ffabd to
e2c6334
Compare
f5d31a8 to
9dc842c
Compare
|
A really useful feat. |
9b50948 to
bd7fff5
Compare
|
Hello @fabiovincenzi -- I found your open PR while trying to solve a similar issue where the reverse proxy injects a Use caseJupyterHub's Proposed addition to
|
…enzi/opencode into feat/base-path-support
|
Hey @awschmeder, great suggestion! I've implemented exactly this, the Thanks for the detailed write-up, it made the implementation straightforward! |
# Conflicts: # packages/opencode/src/server/routes/instance/httpapi/server.ts # packages/opencode/src/server/server.ts
…enzi/opencode into feat/base-path-support
|
Hi @Hona @Brendonovich, this PR adds base path support for reverse proxy deployments. Would love your feedback when you have a moment! |
# Conflicts: # packages/opencode/src/server/routes/instance/httpapi/server.ts
|
This feature is really useful! I hope they include it. For now, I’m testing it on your branch. Thanks for all your hard work @fabiovincenzi and @awschmeder 💯 |
# Conflicts: # packages/app/src/env.d.ts
…t/base-path-support
Issue for this PR
Closes #7624
Type of change
What does this PR do?
Adds a
--base-pathflag (alsoserver.basePathin config) so opencode web works behind a reverse proxy at a prefix likeplatform.com/opencode/.The server strips the prefix before routing, redirects
/opencodeto/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, ranopencode 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.
18 unit tests covering normalization, HTML injection, XSS prevention, and CSP hash computation.
Screenshots / recordings
N/A - no visual changes, only routing behavior.
Checklist