diff --git a/ui/src/index.tsx b/ui/src/index.tsx index 907c071dd..c076f29b9 100644 --- a/ui/src/index.tsx +++ b/ui/src/index.tsx @@ -12,6 +12,7 @@ import configureStore from 'src/store/configureStore' import {loadLocalStorage} from 'src/localStorage' import {getRootNode} from 'src/utils/nodes' +import {getBasepath} from 'src/utils/basepath' import App from 'src/App' import { @@ -52,6 +53,8 @@ const errorsQueue = [] const rootNode = getRootNode() +const basepath = getBasepath() + declare global { interface Window { basepath: string @@ -59,7 +62,6 @@ declare global { } // Older method used for pre-IE 11 compatibility -const basepath = rootNode.getAttribute('data-basepath') || '' window.basepath = basepath const browserHistory = useRouterHistory(createHistory)({ diff --git a/ui/src/utils/basepath.ts b/ui/src/utils/basepath.ts new file mode 100644 index 000000000..236304947 --- /dev/null +++ b/ui/src/utils/basepath.ts @@ -0,0 +1,6 @@ +import {getRootNode} from 'src/utils/nodes' + +export const getBasepath = () => { + const rootNode = getRootNode() + return rootNode.getAttribute('data-basepath') || '' +}