summaryrefslogtreecommitdiffstats
path: root/src/api/apiBase.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/apiBase.js')
-rw-r--r--src/api/apiBase.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
new file mode 100644
index 000000000..42f09eaa8
--- /dev/null
+++ b/src/api/apiBase.js
@@ -0,0 +1,25 @@
1/**
2 * Get API base URL from store
3 */
4import {
5 API_VERSION,
6 API,
7} from '../environment';
8
9const apiBase = () => {
10 let url;
11 if (!window.ferdi.stores.settings || !window.ferdi.stores.settings.all) {
12 // Stores have not yet been loaded - send invalid URL to force a retry when stores are loaded
13 url = 'https://localhost:9999';
14 } else if (window.ferdi.stores.settings.all.app.server) {
15 // Load URL from store
16 url = window.ferdi.stores.settings.all.app.server;
17 } else {
18 // Use default server url
19 url = API;
20 }
21
22 return `${url}/${API_VERSION}`;
23};
24
25export default apiBase;