diff options
Diffstat (limited to 'src/api/apiBase.ts')
-rw-r--r-- | src/api/apiBase.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/api/apiBase.ts b/src/api/apiBase.ts index 701919785..974d513a1 100644 --- a/src/api/apiBase.ts +++ b/src/api/apiBase.ts | |||
@@ -34,6 +34,23 @@ export default function apiBase(withVersion = true) { | |||
34 | return fixUrl(withVersion ? `${url}/${API_VERSION}` : url); | 34 | return fixUrl(withVersion ? `${url}/${API_VERSION}` : url); |
35 | }; | 35 | }; |
36 | 36 | ||
37 | export function needsToken(): boolean { | ||
38 | return (window as any).ferdium.stores.settings.all.app.server === LOCAL_SERVER; | ||
39 | } | ||
40 | |||
41 | export function localServerToken(): string | undefined { | ||
42 | return needsToken() | ||
43 | ? (window as any).ferdium.stores.requests.localServerToken | ||
44 | : undefined; | ||
45 | } | ||
46 | |||
47 | export function importExportURL() { | ||
48 | const base = apiBase(false); | ||
49 | return needsToken() | ||
50 | ? `${base}/token/${localServerToken()}` | ||
51 | : base; | ||
52 | } | ||
53 | |||
37 | export function serverBase() { | 54 | export function serverBase() { |
38 | const serverType = (window as any).ferdium.stores.settings.all.app.server; | 55 | const serverType = (window as any).ferdium.stores.settings.all.app.server; |
39 | const noServer = 'You are using Ferdium without a server'; | 56 | const noServer = 'You are using Ferdium without a server'; |