Uh oh!
There was an error while loading. Please reload this page.
feat: App - Support setting base URL during build - #18209
Conversation
The following comment was made by an LLM, it may be inaccurate: |
4f6cd85 to
2a38d6fCompare2a38d6f to
3d3f166Compareeinarpersson
commented
Apr 21, 2026
If this works, I think this approach seems good as it has very few changes to the codebase and thus feels less brittle than patching everywhere. I want to host opencode behind Caddy and tailscale (the latter not allowing for subdomains atm). |
solarkraft
commented
May 6, 2026
I have tested this and it works great! Same use case, comfortably statically hosting with Caddy now! |
3d3f166 to
0f54a7cCompare0f54a7c to
fbd733cCompareArk-kun
commented
Jun 29, 2026
Hello, @Brendonovich. and @Hona . Would you please take a look at this PR? It's just couple simple lines of code, but if you have any concerns, our company can set up a video meeting so that we can explain each line. |
fbd733c to
fe53a70CompareArk-kun
commented
Aug 3, 2026
@thdxr@Brendonovich@Hona@rekram1-node@adamdotdevin Can you please take a look? It's 6 lines of code... |
This is needed to host OpenCode app under under some URL prefix. This minimal change makes it possible to build OpenCode Web App with VITE_BASE_URL="/subdir/" and have it run under `http://<host>:<port>/subdir/` instead of root (`http://<host>:<port>/`). Set `VITE_BASE_URL` env var during build. This automatically sets the `base` in Vite config. Vite generates correct URLs in `index.html`. `import.meta.env.BASE_URL` is also used in routers. See https://vite.dev/config/shared-options#base You can also set `VITE_OPENCODE_SERVER_BASE_URL` to specify the base URL prefix for the server. Usage: ``` % VITE_BASE_URL="/XXX" VITE_OPENCODE_SERVER_BASE_URL="/" bun dev $ vite (!) "base" option should start with a slash. VITE v7.1.4 ready in 320 ms ➜ Local: http://localhost:3000/XXX ```
fe53a70 to
a5a0a1aCompare…e consumer code is sensitive to it For example, ~18 tests (e.g. e2e/regression/legacy-new-session.spec.ts) fail on "http://127.0.0.1:4096/", but succeed on "http://127.0.0.1:4096". See https://github.com/anomalyco/opencode/actions/runs/31237532949/job/93052787926?pr=18209
Head branch was pushed to by a user without write access
Ark-kun
commented
Aug 8, 2026
@Brendonovich Thank you for approving my PR. Thanks for improving the code. Your 1c15cef commit made the code more elegant. However, it changed the behavior slightly ( |
This is needed to host OpenCode app under under some URL prefix. Usage: Set
VITE_BASE_URLenv var during build. This automatically sets thebasein Vite config. It's also used in routers.See https://vite.dev/config/shared-options#base
Issue for this PR
Issue: #7624
Type of change
What does this PR do?
This change is needed to host OpenCode app under under some URL prefix.
This tiny PR makes it possible to build OpenCode Web App with VITE_BASE_URL="/subdir/" and have it run under
http://<host>:<port>/subdir/instead of root (http://<host>:<port>/).Set
VITE_BASE_URLenv var during build. This automatically sets thebasein Vite config. Vite generates correct URLs inindex.html.import.meta.env.BASE_URLis also used in routers. See https://vite.dev/config/shared-options#baseYou can also set
VITE_OPENCODE_SERVER_BASE_URLto specify the base URL prefix for the server.How did you verify your code works?
Checklist
If you do not follow this template your PR will be automatically rejected.