diff --git a/.env b/.env index 86feafaa143..6ac42ba97b4 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ VITE_BYPASS_LOGIN=0 -VITE_BYPASS_TUTORIAL=0 \ No newline at end of file +VITE_BYPASS_TUTORIAL=0 +VITE_SERVER_URL=http://localhost:8001 \ No newline at end of file diff --git a/.env.development b/.env.development index 88dcdce619c..e9180f0875d 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,3 @@ VITE_BYPASS_LOGIN=1 -VITE_BYPASS_TUTORIAL=0 \ No newline at end of file +VITE_BYPASS_TUTORIAL=0 +VITE_SERVER_URL=http://localhost:8001 \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 42736add1fa..7b25c4990e1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -277,8 +277,10 @@ export const isLocal = ( /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) && window.location.port !== "") || window.location.hostname === ""; +export const localServerUrl = import.meta.env.VITE_SERVER_URL ?? `http://${window.location.hostname}:${window.location.port+1}`; + // Set the server URL based on whether it's local or not -export const serverUrl = isLocal ? `${window.location.hostname}:${window.location.port}` : ""; +export const serverUrl = isLocal ? localServerUrl : ""; export const apiUrl = isLocal ? serverUrl : "https://api.pokerogue.net"; // used to disable api calls when isLocal is true and a server is not found export let isLocalServerConnected = false; diff --git a/src/vite.env.d.ts b/src/vite.env.d.ts index 50bb7dddc02..b588b5b1145 100644 --- a/src/vite.env.d.ts +++ b/src/vite.env.d.ts @@ -4,6 +4,7 @@ interface ImportMetaEnv { readonly VITE_BYPASS_LOGIN?: string; readonly VITE_BYPASS_TUTORIAL?: string; readonly VITE_API_BASE_URL?: string; + readonly VITE_SERVER_URL?: string; } interface ImportMeta {