projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into 14039-details-view-improvements
[arvados.git]
/
src
/
common
/
config.ts
diff --git
a/src/common/config.ts
b/src/common/config.ts
index 5391927e21dd7525a72dd5a97abb3273d76f454b..759a20158f9f8cafac459cd4ee2213f36c00890d 100644
(file)
--- a/
src/common/config.ts
+++ b/
src/common/config.ts
@@
-2,29
+2,34
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// 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";
export interface Config {
export const CONFIG_URL = process.env.REACT_APP_ARVADOS_CONFIG_URL || "/config.json";
export interface Config {
-
API_HOST
: string;
-
KEEP_WEB_HOST
: string;
+
apiHost
: string;
+
keepWebHost
: string;
}
export const fetchConfig = () => {
return Axios
}
export const fetchConfig = () => {
return Axios
- .get<Config>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
+ .get<Config
JSON
>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
.then(response => response.data)
.catch(() => Promise.resolve(getDefaultConfig()))
.then(mapConfig);
};
.then(response => response.data)
.catch(() => Promise.resolve(getDefaultConfig()))
.then(mapConfig);
};
-const mapConfig = (config: Config): Config => ({
- ...config,
- API_HOST: addProtocol(config.API_HOST)
+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 => ({
+const getDefaultConfig = (): Config
JSON
=> ({
API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
KEEP_WEB_HOST: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || ""
});
API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
KEEP_WEB_HOST: process.env.REACT_APP_ARVADOS_KEEP_WEB_HOST || ""
});