Skip to content

Commit

Permalink
fix: use core AppHub proxy instead of apps.dhis2.org (#137) (#138)
Browse files Browse the repository at this point in the history
(cherry picked from commit 5e35a09)
  • Loading branch information
amcgee authored Sep 8, 2020
1 parent 723a4a0 commit 3eee6c6
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,39 +101,21 @@ actions.loadAppHub.subscribe(async () => {
},
}

const getAppHubUrl = async () => {
const response = await fetch(
`${baseUrl}/configuration/appHubUrl`,
fetchOptions
)
const dhis2Configuration = await response.json()
return dhis2Configuration.apiUrl
}

const getDhisVersion = async () => {
const response = await fetch(`${baseUrl}/system/info`, fetchOptions)
const json = await response.json()
//if we're running a dev version remove the snapshot suffix to just keep the dhis version
return json.version.replace('-SNAPSHOT', '')
}

const url = await getAppHubUrl()
debug(`Got apphub url: ${url}`)

const version = await getDhisVersion()
debug(`Got dhis2 version: ${version}`)

const corsOptions = {
...fetchOptions,
mode: 'cors',
credentials: undefined,
}
debug('Using fetch/cors options:', corsOptions)

const response = await fetch(
`${url}/apps?dhis_version=${version}`,
corsOptions
`${baseUrl}/appHub/v1/apps?dhis_version=${version}`,
fetchOptions
)

const apps = await response.json()
appHubStore.setState(Object.assign(appHubStore.getState() || {}, { apps }))
})
Expand Down

0 comments on commit 3eee6c6

Please sign in to comment.