diff --git a/adapter/src/components/ServerVersionProvider.js b/adapter/src/components/ServerVersionProvider.js index 6dfc87cc..370eb891 100644 --- a/adapter/src/components/ServerVersionProvider.js +++ b/adapter/src/components/ServerVersionProvider.js @@ -8,6 +8,9 @@ import { LoadingMask } from './LoadingMask.js' import { LoginModal } from './LoginModal.js' import { useOfflineInterface } from './OfflineInterfaceContext.js' +// Save this location so that it's usable after client-side navigations +const originalWindowLocation = new URL(window.location) + export const ServerVersionProvider = ({ appName, appVersion, @@ -148,6 +151,9 @@ export const ServerVersionProvider = ({ return } + // Make sure the base URL is absolute to avoid errors with relative URLs after + // client-side navigation/route changes + const absoluteBaseUrl = new URL(baseUrl, originalWindowLocation).href const serverVersion = parseDHIS2ServerVersion(systemInfo.version) const realApiVersion = serverVersion.minor @@ -156,7 +162,7 @@ export const ServerVersionProvider = ({ config={{ appName, appVersion: parseVersion(appVersion), - baseUrl, + baseUrl: absoluteBaseUrl, apiVersion: apiVersion || realApiVersion, serverVersion, systemInfo,