getServerURL() utility function

This commit is contained in:
Oliver Bryan
2025-12-31 17:00:38 +00:00
parent cb21564c11
commit c7d261048b
8 changed files with 30 additions and 30 deletions

View File

@@ -18,3 +18,16 @@ export function getAuthHeaders(): HeadersInit {
export function capitalise(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
const ENV_SERVER_URL = import.meta.env.VITE_SERVER_URL?.trim();
export function getServerURL() {
let serverURL =
localStorage.getItem("serverURL") || // user-defined server URL
ENV_SERVER_URL || // environment variable
"https://eussi.ob248.com"; // fallback
if (serverURL.endsWith("/")) {
serverURL = serverURL.slice(0, -1);
}
return serverURL;
}