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<ConfigJSON>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
17 .then(response => response.data)
18 .catch(() => Promise.resolve(getDefaultConfig()))
22 interface ConfigJSON {
24 KEEP_WEB_HOST: string;
27 const mapConfig = (config: ConfigJSON): Config => ({
28 apiHost: addProtocol(config.API_HOST),
29 keepWebHost: addProtocol(config.KEEP_WEB_HOST)
32 const getDefaultConfig = (): ConfigJSON => ({
33 API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
34 KEEP_WEB_HOST: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || ""
37 const addProtocol = (url: string) => `${window.location.protocol}//${url}`;