[QoL] Added https and server url is read from the env now (#1764)
* Added https and server url is read from the env now * Added the new key to the vite.env.d.ts
This commit is contained in:
parent
7c3ace7204
commit
97dde2d1f3
3
.env
3
.env
|
@ -1,2 +1,3 @@
|
|||
VITE_BYPASS_LOGIN=0
|
||||
VITE_BYPASS_TUTORIAL=0
|
||||
VITE_BYPASS_TUTORIAL=0
|
||||
VITE_SERVER_URL=http://localhost:8001
|
|
@ -1,2 +1,3 @@
|
|||
VITE_BYPASS_LOGIN=1
|
||||
VITE_BYPASS_TUTORIAL=0
|
||||
VITE_BYPASS_TUTORIAL=0
|
||||
VITE_SERVER_URL=http://localhost:8001
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue