Add optional BASE_PREFIX to serve the site under a sub-directory#630
Merged
DeviaVir merged 2 commits intoJun 22, 2026
Merged
Conversation
Introduce a BASE_PREFIX build option that prepends a path segment to each flavor's BASE_HREF, so the whole multi-network site can be served from a sub-directory (e.g. BASE_PREFIX=preview -> /preview/, /preview/signet/, /preview/liquid/, ...) instead of the domain root. The prefix is applied after the flavor config resolves its per-network BASE_HREF, so the network paths are preserved. API_URL is resolved before the prefix is applied and is left un-prefixed, so a prefixed build keeps talking to the same API backend. Cross-network links that are absolute (the network switcher and the Explorer API tab) are routed through the prefix so they stay within the current deployment root. With no BASE_PREFIX set the output is unchanged.
There was a problem hiding this comment.
Pull request overview
This PR introduces an optional BASE_PREFIX build option to allow deploying the multi-network Esplora UI under a sub-directory (e.g. /preview/...) while keeping API requests un-prefixed so the UI can still target the same backend paths.
Changes:
- Add
BASE_PREFIXsupport inbuild.shby prefixing each flavor’s resolvedBASE_HREF(but leavingAPI_URLunchanged). - Update cross-network UI links (network switcher, nav toggle) to respect the deployment root prefix.
- Document the new
BASE_PREFIXoption inREADME.md.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new BASE_PREFIX build option and intended behavior. |
| build.sh | Applies BASE_PREFIX after flavor config resolves BASE_HREF, keeping API_URL un-prefixed. |
| client/src/views/network-selection.js | Prefixes cross-network menu links with the deployment root. |
| client/src/views/nav-toggle.js | Prefixes hardcoded cross-network explorer links with the deployment root. |
| client/src/views/navbar.js | Updates the “Explorer API” nav link to incorporate the deployment root prefix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Randy808
previously approved these changes
Jun 22, 2026
The Explorer API link was the only absolute navbar link (/explorer-api).
The router strips the full BASE_HREF before matching route('/explorer-api'),
so under a sub-directory or non-root network the absolute path never
matches. Use a relative href, consistent with the Dashboard/Blocks/
Transactions links, so it resolves against BASE_HREF and stays within the
current network and deployment root.
Randy808
approved these changes
Jun 22, 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.
What
Adds an optional
BASE_PREFIXbuild option so the whole multi-network site can be served from a sub-directory instead of the domain root.Setting
BASE_PREFIX=previewproduces a build served at:/preview/(bitcoin mainnet)/preview/signet/,/preview/testnet/, .../preview/liquid/,/preview/liquidtestnet/, ...This is useful for hosting more than one build of the explorer side by side under a single host (e.g. a long-lived branch/preview build alongside the main one).
How it works
build.shappliesBASE_PREFIXafter each flavor'sconfig.envresolves its per-networkBASE_HREF, so the network sub-paths are preserved (/signet/→/preview/signet/).API_URLis resolved before the prefix is applied and is left un-prefixed, so a prefixed build keeps talking to the same API backend rather than expecting a prefixed API.network-selection.js/nav-toggle.js, and the Explorer API tab innavbar.js) are routed through the prefix so they stay within the current deployment root instead of jumping back to/.Compatibility
BASE_PREFIXis optional and defaults to empty. With no prefix set the build output and all links are unchanged.Notes
prerender-serveris not covered by this change.