mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-15 03:25:42 +00:00
[P UI] Make base url configurable (#5577)
* made url_base configurable for P UI * fixed test for configurable base url
This commit is contained in:
@ -14,6 +14,7 @@ declare global {
|
||||
server_list: HostList;
|
||||
default_server: string;
|
||||
show_server_selector: boolean;
|
||||
url_base: string;
|
||||
sentry_dsn?: string;
|
||||
environment?: string;
|
||||
};
|
||||
@ -55,13 +56,15 @@ if (window.INVENTREE_SETTINGS.sentry_dsn) {
|
||||
});
|
||||
}
|
||||
|
||||
export const url_base = window.INVENTREE_SETTINGS.url_base || 'platform';
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
// Redirect to /platform if on /
|
||||
// Redirect to base url if on /
|
||||
if (window.location.pathname === '/') {
|
||||
window.location.replace('/platform');
|
||||
window.location.replace(`/${url_base}`);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { BrowserRouter } from 'react-router-dom';
|
||||
import { queryClient, setApiDefaults } from '../App';
|
||||
import { BaseContext } from '../contexts/BaseContext';
|
||||
import { defaultHostList } from '../defaults/defaultHostList';
|
||||
import { url_base } from '../main';
|
||||
import { routes } from '../router';
|
||||
import { useApiState } from '../states/ApiState';
|
||||
import { useLocalState } from '../states/LocalState';
|
||||
@ -35,7 +36,7 @@ export default function DesktopAppView() {
|
||||
return (
|
||||
<BaseContext>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter basename="platform">{routes}</BrowserRouter>
|
||||
<BrowserRouter basename={url_base}>{routes}</BrowserRouter>
|
||||
</QueryClientProvider>
|
||||
</BaseContext>
|
||||
);
|
||||
|
Reference in New Issue
Block a user