From 300da50e5620533ba9a86a716c52494052957c69 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Tue, 17 Dec 2024 12:02:11 +0100 Subject: [PATCH] fix: fix error with relative baseUrl This happens in prod, where the baseUrl returned by useConfig is a relative URL. The URL constructor needs an absolute URL for the base parameter. --- src/components/DataDimension/Info/CalculationInfo.js | 2 +- src/components/DataDimension/Info/DataElementOperandInfo.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/DataDimension/Info/CalculationInfo.js b/src/components/DataDimension/Info/CalculationInfo.js index 980f889ca..46ff20825 100644 --- a/src/components/DataDimension/Info/CalculationInfo.js +++ b/src/components/DataDimension/Info/CalculationInfo.js @@ -53,7 +53,7 @@ export const CalculationInfo = ({ id, displayNameProp }) => { // inject href as it is not returned from the API calculation.href = new URL( `${calculationQuery.calculation.resource}/${id}`, - new URL(`api/${apiVersion}/`, `${baseUrl}/`) + new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`) ).href setData({ calculation }) diff --git a/src/components/DataDimension/Info/DataElementOperandInfo.js b/src/components/DataDimension/Info/DataElementOperandInfo.js index 622a899ff..d5442d677 100644 --- a/src/components/DataDimension/Info/DataElementOperandInfo.js +++ b/src/components/DataDimension/Info/DataElementOperandInfo.js @@ -66,7 +66,7 @@ export const DataElementOperandInfo = ({ id, displayNameProp }) => { `${ dataElementOperandsQuery.dataElementOperands.resource }?${new URLSearchParams({ filter: `id:eq:${id}` })}`, - new URL(`api/${apiVersion}/`, `${baseUrl}/`) + new URL(`api/${apiVersion}/`, baseUrl === '..' ? window.location.href.split('dhis-web-data-visualizer/')[0] : `${baseUrl}/`) ).href setData({ dataElementOperand })