diff --git a/ui/public/index.html b/ui/public/index.html index 0f51e6aca..5d50c3ffa 100644 --- a/ui/public/index.html +++ b/ui/public/index.html @@ -4,7 +4,7 @@ Shibboleth IDP UI - + diff --git a/ui/src/app/App.router.js b/ui/src/app/App.router.js index 04f434c20..ed514855c 100644 --- a/ui/src/app/App.router.js +++ b/ui/src/app/App.router.js @@ -413,5 +413,5 @@ export const router = createBrowserRouter([ ] } ], { - basename: BASE_PATH + basename: `/${BASE_PATH}` }); diff --git a/ui/src/app/core/components/VersionInfo.js b/ui/src/app/core/components/VersionInfo.js index a833cec08..d687e810e 100644 --- a/ui/src/app/core/components/VersionInfo.js +++ b/ui/src/app/core/components/VersionInfo.js @@ -16,7 +16,7 @@ export function VersionInfo () { 'mode':'no-cors' } } - const { data = {} } = useFetch(`${ACTUATOR_PATH}/info`, opts, []); + const { data = {} } = useFetch(`${ACTUATOR_PATH}info`, opts, []); const [ versionData, setVersionData ] = React.useState(''); diff --git a/ui/src/app/store/baseQuery.js b/ui/src/app/store/baseQuery.js index 16aaca37d..cae6e0004 100644 --- a/ui/src/app/store/baseQuery.js +++ b/ui/src/app/store/baseQuery.js @@ -3,7 +3,7 @@ import API_BASE_PATH from '../App.constant'; import { get_cookie } from '../core/utility/get_cookie'; export const getBaseQuery = (config = {}) => fetchBaseQuery({ - baseUrl: `${API_BASE_PATH}`, + baseUrl: `/${API_BASE_PATH}`, prepareHeaders: (headers) => { const token = get_cookie('XSRF-TOKEN'); diff --git a/ui/src/setupProxy.js b/ui/src/setupProxy.js index bbd4523b8..7b03bee2e 100644 --- a/ui/src/setupProxy.js +++ b/ui/src/setupProxy.js @@ -1,15 +1,23 @@ const { createProxyMiddleware } = require('http-proxy-middleware'); + + module.exports = function (app) { const port = 8080; + const context = process.env.PUBLIC_URL; + + const rewriteFn = function (path, req) { + return path.replace(context, ''); + }; app.use( - '/api', + `${context}/api`, createProxyMiddleware({ - target: `http://localhost:${port}`, + target: `http://localhost:${port}${context}/`, changeOrigin: true, + pathRewrite: rewriteFn, onProxyRes: function (proxyRes, req, res) { proxyRes.headers['Access-Control-Allow-Origin'] = '*'; } @@ -17,26 +25,38 @@ module.exports = function (app) { ); app.use( - '/actuator', + `${context}/actuator`, + createProxyMiddleware({ + target: `http://localhost:${port}${context}/`, + changeOrigin: true, + pathRewrite: rewriteFn, + }) + ); + + app.use( + `${context}/login`, createProxyMiddleware({ - target: `http://localhost:${port}`, - changeOrigin: true + target: `http://localhost:${port}${context}/`, + changeOrigin: true, + pathRewrite: rewriteFn, }) ); app.use( - '/login', + `${context}/info`, createProxyMiddleware({ - target: `http://localhost:${port}`, - changeOrigin: true + target: `http://localhost:${port}${context}/`, + changeOrigin: true, + pathRewrite: rewriteFn, }) ); app.use( - '/logout', + `${context}/logout`, createProxyMiddleware({ - target: `http://localhost:${port}`, - changeOrigin: true + target: `http://localhost:${port}${context}/`, + changeOrigin: true, + pathRewrite: rewriteFn, }) ); };