1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import Axios from "axios";
7 export const CONFIG_URL = process.env.REACT_APP_ARVADOS_CONFIG_URL || "/config.json";
9 export interface Config {
14 export const fetchConfig = () => {
16 .get<Config>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
17 .then(response => response.data)
18 .catch(() => Promise.resolve(getDefaultConfig()))
22 const mapConfig = (config: Config): Config => ({
24 apiHost: addProtocol(config.apiHost),
25 keepWebHost: addProtocol(config.keepWebHost)
28 const getDefaultConfig = (): Config => ({
29 apiHost: process.env.REACT_APP_ARVADOS_API_HOST || "",
30 keepWebHost: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || ""
33 const addProtocol = (url: string) => `${window.location.protocol}//${url}`;