diff --git a/src/server/apps.ts b/src/server/apps.ts index 1c31fc6..b8096ee 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -2,6 +2,7 @@ import type { App as SharedApp, AppState } from '@types' import type { Subprocess } from 'bun' import { DEFAULT_EMOJI } from '@types' import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, symlinkSync, unlinkSync, writeFileSync } from 'fs' +import { hostname } from 'os' import { join, resolve } from 'path' import { loadAppEnv } from '../tools/env' import { appLog, hostLog, setApps } from './tui' @@ -10,7 +11,9 @@ export type { AppState } from '@types' export const APPS_DIR = process.env.APPS_DIR ?? resolve(join(process.env.DATA_DIR ?? '.', 'apps')) export const TOES_DIR = process.env.TOES_DIR ?? join(process.env.DATA_DIR ?? '.', 'toes') -export const TOES_URL = process.env.TOES_URL ?? `http://localhost:${process.env.PORT || 3000}` + +const defaultHost = process.env.NODE_ENV === 'production' ? `${hostname()}.local` : 'localhost' +export const TOES_URL = process.env.TOES_URL ?? `http://${defaultHost}:${process.env.PORT || 3000}` const HEALTH_CHECK_FAILURES_BEFORE_RESTART = 3 const HEALTH_CHECK_INTERVAL = 30000