diff --git a/src/utils.ts b/src/utils.ts index 142de91c1ca..92860ce2361 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -215,8 +215,13 @@ export function executeIf(condition: boolean, promiseFunc: () => Promise): } export const sessionIdKey = 'pokerogue_sessionId'; -export const isLocal = window.location.hostname === 'localhost' || window.location.hostname === ''; -export const serverUrl = isLocal ? 'http://localhost:8001' : ''; +// Check if the current hostname is 'localhost' or an IP address, and ensure a port is specified +export const isLocal = (window.location.hostname === 'localhost' || + /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(window.location.hostname)) && + window.location.port !== ''; + +// Set the server URL based on whether it's local or not +export const serverUrl = isLocal ? `${window.location.hostname}:${window.location.port}` : ''; export const apiUrl = isLocal ? serverUrl : 'https://api.pokerogue.net'; export function setCookie(cName: string, cValue: string): void {