mirror of
https://github.com/ReVanced/revanced-website.git
synced 2026-01-18 08:43:56 +00:00
feat(api): set default api url with env var
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
import { browser } from "$app/environment";
|
||||
import { browser } from '$app/environment';
|
||||
import { RV_API_URL } from '$env/static/public';
|
||||
|
||||
const URL_KEY = "revanced_api_url";
|
||||
const URL_KEY = 'revanced_api_url';
|
||||
|
||||
export const default_base_url = "https://releases.revanced.app";
|
||||
export const default_base_url = RV_API_URL;
|
||||
|
||||
// Get base URL
|
||||
export function api_base_url(): string {
|
||||
if (browser) {
|
||||
return localStorage.getItem(URL_KEY) || default_base_url;
|
||||
}
|
||||
if (browser) {
|
||||
return localStorage.getItem(URL_KEY) || default_base_url;
|
||||
}
|
||||
|
||||
return default_base_url;
|
||||
return default_base_url;
|
||||
}
|
||||
|
||||
// (re)set base URL.
|
||||
export function set_api_base_url(url?: string) {
|
||||
if (!url) {
|
||||
localStorage.removeItem(URL_KEY);
|
||||
} else {
|
||||
localStorage.setItem(URL_KEY, url);
|
||||
}
|
||||
if (!url) {
|
||||
localStorage.removeItem(URL_KEY);
|
||||
} else {
|
||||
localStorage.setItem(URL_KEY, url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user