Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use core AppHub proxy instead of apps.dhis2.org #137

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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