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
This commit is contained in:
Willie
2026-03-18 22:35:02 +08:00
parent 04f65e5320
commit 214c8b993c
3 changed files with 6 additions and 2 deletions
+3 -1
View File
@@ -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() {
<ThemeProvider>
<ToastProvider>
<AppProvider>
<BrowserRouter>
<BrowserRouter basename={basePath}>
<ErrorBoundary>
<TourProvider>
<TourOverlay />
+2 -1
View File
@@ -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;
+1
View File
@@ -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',