diff --git a/.env b/.env index 86feafaa1..bb76f22b4 100644 --- a/.env +++ b/.env @@ -1,2 +1,5 @@ -VITE_BYPASS_LOGIN=0 -VITE_BYPASS_TUTORIAL=0 \ No newline at end of file +# Production environment +VITE_ENVIRONMENT="production" +VITE_API_BASE_URL="api" +VITE_BYPASS_LOGIN=false +VITE_BYPASS_TUTORIAL=false \ No newline at end of file diff --git a/.env.development b/.env.development index 88dcdce61..effc4f158 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,5 @@ -VITE_BYPASS_LOGIN=1 -VITE_BYPASS_TUTORIAL=0 \ No newline at end of file +# Development environment +VITE_ENVIRONMENT="local" +VITE_API_BASE_URL="http://localhost:8001" +VITE_BYPASS_LOGIN=true +VITE_BYPASS_TUTORIAL=false \ No newline at end of file diff --git a/src/battle-scene.ts b/src/battle-scene.ts index e89874a07..938e6e858 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -63,7 +63,7 @@ import { STARTING_WAVE_OVERRIDE, OPP_SPECIES_OVERRIDE, SEED_OVERRIDE, STARTING_B import {InputsController} from "./inputs-controller"; import {UiInputs} from "./ui-inputs"; -export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1"; +export const bypassLogin = Boolean(import.meta.env.VITE_BYPASS_LOGIN); const DEBUG_RNG = false; @@ -94,7 +94,7 @@ export default class BattleScene extends SceneBase { public gameSpeed: integer = 1; public damageNumbersMode: integer = 0; public showLevelUpStats: boolean = true; - public enableTutorials: boolean = import.meta.env.VITE_BYPASS_TUTORIAL === "1"; + public enableTutorials: boolean = Boolean(import.meta.env.VITE_BYPASS_TUTORIAL); public enableRetries: boolean = false; public uiTheme: UiTheme = UiTheme.DEFAULT; public windowType: integer = 0; diff --git a/src/utils.ts b/src/utils.ts index 822f02f05..f5a0b845d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -220,9 +220,8 @@ export function executeIf(condition: boolean, promiseFunc: () => Promise): } export const sessionIdKey = 'pokerogue_sessionId'; -export const isLocal = window.location.hostname === 'localhost'; -export const serverUrl = isLocal ? 'http://localhost:8001' : ''; -export const apiUrl = isLocal ? serverUrl : 'api'; +export const isLocal = import.meta.env.VITE_ENVIRONMENT === 'local'; +export const apiUrl = import.meta.env.VITE_API_BASE_URL || (!isLocal ? 'api' : ''); export function setCookie(cName: string, cValue: string): void { const expiration = new Date(); diff --git a/vite.env.d.ts b/src/vite-env.d.ts similarity index 56% rename from vite.env.d.ts rename to src/vite-env.d.ts index 1bb3a15b5..801785b63 100644 --- a/vite.env.d.ts +++ b/src/vite-env.d.ts @@ -1,9 +1,10 @@ /// interface ImportMetaEnv { - readonly VITE_BYPASS_LOGIN: string; - readonly VITE_BYPASS_TUTORIAL: string; + readonly VITE_ENVIRONMENT: string; readonly VITE_API_BASE_URL: string; + readonly VITE_BYPASS_LOGIN: boolean; + readonly VITE_BYPASS_TUTORIAL: boolean; } interface ImportMeta {