From 04b81e3c8d09de73dfcf3bb983d197c2544096f7 Mon Sep 17 00:00:00 2001 From: Austin McGee <947888+amcgee@users.noreply.github.com> Date: Tue, 8 Sep 2020 12:38:40 +0200 Subject: [PATCH] fix: use core AppHub proxy instead of apps.dhis2.org --- src/actions.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/src/actions.js b/src/actions.js index 7e32335e..87c516ce 100644 --- a/src/actions.js +++ b/src/actions.js @@ -101,15 +101,6 @@ 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() @@ -117,23 +108,14 @@ actions.loadAppHub.subscribe(async () => { 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 })) })