Skip to content

Commit

Permalink
fix: Use localhost not 127.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
carlreid committed Feb 19, 2025
1 parent 6705df4 commit 066d37d
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/StreamMaster.WebUI/lib/settings.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
// settings.ts

export const isClient = typeof window !== 'undefined';
export const isClient = typeof window !== "undefined";

export const isDev = process.env.NODE_ENV === 'development';
export const isDev = process.env.NODE_ENV === "development";

const loadConfig = () => {
const request = new XMLHttpRequest();
request.open('GET', '/config.json', false); // Synchronous request
request.send(null);
const request = new XMLHttpRequest();
request.open("GET", "/config.json", false); // Synchronous request
request.send(null);

if (request.status === 200) {
return JSON.parse(request.responseText);
} else {
throw new Error(`Failed to load config: ${request.status}`);
}
if (request.status === 200) {
return JSON.parse(request.responseText);
} else {
throw new Error(`Failed to load config: ${request.status}`);
}
};

const config = loadConfig();

export const defaultPort = config.defaultPort;
export const defaultBaseUrl = config.defaultBaseUrl;

export const baseHostURL = isClient && !isDev ? `${window.location.protocol}//${window.location.host}` : `http://127.0.0.1:${defaultPort}${defaultBaseUrl}`;
export const baseHostURL =
isClient && !isDev
? `${window.location.protocol}//${window.location.host}`
: `http://localhost:${defaultPort}${defaultBaseUrl}`;

0 comments on commit 066d37d

Please sign in to comment.