Skip to content

Commit 370c289

Browse files
authored
Add ability to run hamilton-ui on domain subpath (#1284)
* feat: add support for custom sub-path in BrowserRouter * chore: add documentation for ui subpath configuration * docs: clarify subpath environment variable requirement
1 parent 1057a40 commit 370c289

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/hamilton-ui/ui.rst

+8
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ Self-Hosting
118118
If you know docker, you should be good to go. The one environment variable to know is `HAMILTON_ALLOWED_HOSTS`, which you can set to `*` to allow all hosts, or
119119
a comma separated list of hosts you want to allow.
120120

121+
To host the UI on a subpath, set `REACT_APP_HAMILTON_SUB_PATH` to the subpath required. For example, to run on `https://domain.com/hamilton`:
122+
123+
.. code-block:: yaml
124+
125+
- REACT_APP_HAMILTON_SUB_PATH=/hamilton
126+
127+
Make sure that the sub path environment variable begins with `/` if set.
128+
121129
Please reach out to us if you want to deploy on your own infrastructure and need help - `join slack <https://join.slack.com/t/hamilton-opensource/shared_invite/zt-2niepkra8-DGKGf_tTYhXuJWBTXtIs4g>`_.
122130
More extensive self-hosting documentation is in the works, e.g. Snowflake, Databricks, AWS, GCP, Azure, etc.; we'd love a helm
123131
chart contribution!

ui/frontend/src/App.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { UserContext } from "./auth/Login";
2828
import { LocalAccount } from "./auth/LocalAccount";
2929

3030
export const localMode = process.env.REACT_APP_AUTH_MODE === "local";
31+
export const subPath = process.env.REACT_APP_HAMILTON_SUB_PATH || ""
3132

3233
const useAuthInfoBasedOnProcEnv = () => {
3334
if (localMode) {
@@ -99,7 +100,7 @@ export const App = () => {
99100
includeHelp: true,
100101
}}
101102
>
102-
<BrowserRouter>
103+
<BrowserRouter basename={subPath}>
103104
<Routes>
104105
{localMode && (
105106
<Route path="/" element={<Navigate to="/dashboard/account" />} />

0 commit comments

Comments
 (0)