diff --git a/src/apps/Homepage/Homepage.tsx b/src/apps/Homepage/Homepage.tsx index 0279f175..470168b5 100644 --- a/src/apps/Homepage/Homepage.tsx +++ b/src/apps/Homepage/Homepage.tsx @@ -20,10 +20,7 @@ function getCookie(name: string) { }, ""); } -const apiBase = - typeof window !== "undefined" && window.location.hostname === "localhost" - ? "http://localhost:8081/users" - : "/users"; +const apiBase = import.meta.env.DEV ? "http://localhost:8081/users" : "/users"; const API = axios.create({ baseURL: apiBase, diff --git a/src/apps/Homepage/HomepageAuth.tsx b/src/apps/Homepage/HomepageAuth.tsx index 185ac43d..3ad1b24a 100644 --- a/src/apps/Homepage/HomepageAuth.tsx +++ b/src/apps/Homepage/HomepageAuth.tsx @@ -19,10 +19,7 @@ function getCookie(name: string) { }, ""); } -const apiBase = - typeof window !== "undefined" && window.location.hostname === "localhost" - ? "http://localhost:8081/users" - : "/users"; +const apiBase = import.meta.env.DEV ? "http://localhost:8081/users" : "/users"; const API = axios.create({ baseURL: apiBase, diff --git a/src/apps/Homepage/HomepageSidebar.tsx b/src/apps/Homepage/HomepageSidebar.tsx index 30f4e524..ec2af144 100644 --- a/src/apps/Homepage/HomepageSidebar.tsx +++ b/src/apps/Homepage/HomepageSidebar.tsx @@ -59,10 +59,7 @@ function getCookie(name: string) { }, ""); } -const apiBase = - typeof window !== "undefined" && window.location.hostname === "localhost" - ? "http://localhost:8081/users" - : "/users"; +const apiBase = import.meta.env.DEV ? "http://localhost:8081/users" : "/users"; const API = axios.create({ baseURL: apiBase, diff --git a/src/apps/Homepage/HompageUpdateLog.tsx b/src/apps/Homepage/HompageUpdateLog.tsx index 3a72c18f..7fdb2383 100644 --- a/src/apps/Homepage/HompageUpdateLog.tsx +++ b/src/apps/Homepage/HompageUpdateLog.tsx @@ -50,10 +50,7 @@ interface VersionResponse { cache_age?: number; } -const apiBase = - typeof window !== "undefined" && window.location.hostname === "localhost" - ? "http://localhost:8081" - : ""; +const apiBase = import.meta.env.DEV ? "http://localhost:8081" : ""; const API = axios.create({ baseURL: apiBase, @@ -70,7 +67,7 @@ export function HomepageUpdateLog({loggedIn}: HomepageUpdateLogProps) { setLoading(true); Promise.all([ API.get('/releases/rss?per_page=100'), - API.get('/version') + API.get('/version/') ]) .then(([releasesRes, versionRes]) => { setReleases(releasesRes.data);