From 214c8b993c8ab0ef51f76d697b25a2dd7c8aa466 Mon Sep 17 00:00:00 2001 From: Willie Date: Wed, 18 Mar 2026 15:35:32 +0800 Subject: [PATCH] feat(ui): support base path for reverse proxy deployments - Vite base: './' for relative asset paths (works from any sub-path) - API client reads window.__BASE_PATH__ for request prefix - React Router uses basename for client-side routing Ref: #85 --- ui/src/App.tsx | 4 +++- ui/src/api/client.ts | 3 ++- ui/vite.config.ts | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/src/App.tsx b/ui/src/App.tsx index ed3af532a..34028785d 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -12,6 +12,8 @@ import Layout from './components/Layout'; import { TourProvider, TourOverlay, TourTooltip } from './components/tour'; import DashboardPage from './pages/DashboardPage'; +const basePath = (window as any).__BASE_PATH__ || ''; + const SkillsPage = lazy(() => import('./pages/SkillsPage')); const SkillDetailPage = lazy(() => import('./pages/SkillDetailPage')); const TargetsPage = lazy(() => import('./pages/TargetsPage')); @@ -41,7 +43,7 @@ export default function App() { - + diff --git a/ui/src/api/client.ts b/ui/src/api/client.ts index 0f6278f36..18a87302a 100644 --- a/ui/src/api/client.ts +++ b/ui/src/api/client.ts @@ -1,4 +1,5 @@ -const BASE = '/api'; +const BASE_PATH = (window as any).__BASE_PATH__ || ''; +const BASE = BASE_PATH + '/api'; export class ApiError extends Error { status: number; diff --git a/ui/vite.config.ts b/ui/vite.config.ts index ffc5f618a..93c11e820 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -8,6 +8,7 @@ import tailwindcss from '@tailwindcss/vite' const SSE_PROXY = { target: 'http://localhost:19420', headers: { Accept: 'text/event-stream' } } export default defineConfig({ + base: './', plugins: [react(), tailwindcss()], test: { environment: 'jsdom',