Skip to content

Commit

Permalink
fix: fix error with relative baseUrl
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
edoardo committed Dec 17, 2024
1 parent d00f3a7 commit 300da50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/DataDimension/Info/CalculationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down

0 comments on commit 300da50

Please sign in to comment.