File size: 558 Bytes
43a06dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { get } from "svelte/store";
import settings from "$lib/state/settings";
import env, { defaultApiURL } from "$lib/env";

export const currentApiURL = () => {
    const processingSettings = get(settings).processing;
    const customInstanceURL = processingSettings.customInstanceURL;

    if (processingSettings.enableCustomInstances && customInstanceURL.length > 0) {
        return new URL(customInstanceURL).origin;
    }

    if (env.DEFAULT_API) {
        return new URL(env.DEFAULT_API).origin;
    }

    return new URL(defaultApiURL).origin;
}