From 502a3cfa131571dfd089404be8644038d43f1ccc Mon Sep 17 00:00:00 2001 From: Andrei Haiducu Date: Fri, 27 Feb 2026 17:58:35 +0200 Subject: [PATCH] Add support for serving the web ui on path specified by http.contextpath --- web-ui/src/App.jsx | 8 +++++++- web-ui/src/services/api.js | 8 +++++++- web-ui/vite.config.js | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/web-ui/src/App.jsx b/web-ui/src/App.jsx index 6916e3b..e7032c9 100644 --- a/web-ui/src/App.jsx +++ b/web-ui/src/App.jsx @@ -9,9 +9,15 @@ import TlsManagement from './pages/TlsManagement' export default function App() { const { isAuthenticated } = useAuth() + const getBasename = () => { + const path = window.location.pathname; + const idx = path.indexOf('/tls-manager'); + return idx !== -1 ? path.substring(0, idx + '/tls-manager'.length) : '/tls-manager'; + }; + return ( - + { + const path = window.location.pathname; + const idx = path.indexOf('/tls-manager'); + return idx !== -1 ? path.substring(0, idx) : '/'; +}; + export const api = axios.create({ // Use same-origin '/api' in dev with Vite proxy; fallback to absolute BASE_URL when building - baseURL: '/', + baseURL: getBasename(), withCredentials: true, headers: { 'X-Requested-With': 'XMLHttpRequest', diff --git a/web-ui/vite.config.js b/web-ui/vite.config.js index 1544eac..e197d99 100644 --- a/web-ui/vite.config.js +++ b/web-ui/vite.config.js @@ -6,7 +6,7 @@ import tailwindcss from '@tailwindcss/vite' // https://vite.dev/config/ export default defineConfig({ plugins: [react(), tailwindcss()], - base: '/tls-manager/', + base: './', server: { allowedHosts: ['localhost', '127.0.0.1', '0.0.0.0', '778ded44be8d.ngrok-free.app'], proxy: {