feat: App - Support setting base URL during build#18209
Open
Ark-kun wants to merge 2 commits intoanomalyco:devfrom
Open
feat: App - Support setting base URL during build#18209Ark-kun wants to merge 2 commits intoanomalyco:devfrom
Ark-kun wants to merge 2 commits intoanomalyco:devfrom
Conversation
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 ```
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
This was referenced Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.