X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3b0011c6f2312bd6517cf470a80b921bd65e86fe..33608c44bf33ab330ad1267ab8d56c08634673b5:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index b898d2b16a..759a20158f 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import Axios from "../../node_modules/axios"; +import Axios from "axios"; export const CONFIG_URL = process.env.REACT_APP_ARVADOS_CONFIG_URL || "/config.json"; @@ -13,21 +13,25 @@ export interface Config { export const fetchConfig = () => { return Axios - .get(CONFIG_URL + "?nocache=" + (new Date()).getTime()) + .get(CONFIG_URL + "?nocache=" + (new Date()).getTime()) .then(response => response.data) .catch(() => Promise.resolve(getDefaultConfig())) .then(mapConfig); }; -const mapConfig = (config: Config): Config => ({ - ...config, - apiHost: addProtocol(config.apiHost), - keepWebHost: addProtocol(config.keepWebHost) +interface ConfigJSON { + API_HOST: string; + KEEP_WEB_HOST: string; +} + +const mapConfig = (config: ConfigJSON): Config => ({ + apiHost: addProtocol(config.API_HOST), + keepWebHost: addProtocol(config.KEEP_WEB_HOST) }); -const getDefaultConfig = (): Config => ({ - apiHost: process.env.REACT_APP_ARVADOS_API_HOST || "", - keepWebHost: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || "" +const getDefaultConfig = (): ConfigJSON => ({ + API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "", + KEEP_WEB_HOST: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || "" }); const addProtocol = (url: string) => `${window.location.protocol}//${url}`;