mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 06:34:35 +02:00
feat(api): set default api url with env var
This commit is contained in:
parent
6c0d95baa2
commit
6ea64ef873
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,8 +4,6 @@ node_modules
|
|||||||
/public
|
/public
|
||||||
/.svelte-kit
|
/.svelte-kit
|
||||||
/package
|
/package
|
||||||
.env
|
|
||||||
.env.*
|
|
||||||
!.env.example
|
!.env.example
|
||||||
/_docs_src
|
/_docs_src
|
||||||
/static/docs
|
/static/docs
|
||||||
|
@ -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
|
// Get base URL
|
||||||
export function api_base_url(): string {
|
export function api_base_url(): string {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
return localStorage.getItem(URL_KEY) || default_base_url;
|
return localStorage.getItem(URL_KEY) || default_base_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default_base_url;
|
return default_base_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
// (re)set base URL.
|
// (re)set base URL.
|
||||||
export function set_api_base_url(url?: string) {
|
export function set_api_base_url(url?: string) {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
localStorage.removeItem(URL_KEY);
|
localStorage.removeItem(URL_KEY);
|
||||||
} else {
|
} else {
|
||||||
localStorage.setItem(URL_KEY, url);
|
localStorage.setItem(URL_KEY, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ const config = {
|
|||||||
pages: "public",
|
pages: "public",
|
||||||
fallback: "404.html"
|
fallback: "404.html"
|
||||||
}),
|
}),
|
||||||
|
env: {
|
||||||
|
publicPrefix: "RV"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user