diff --git a/server/src/tunnel/tunnelManager.ts b/server/src/tunnel/tunnelManager.ts index 1b25c6b0..cdffd345 100644 --- a/server/src/tunnel/tunnelManager.ts +++ b/server/src/tunnel/tunnelManager.ts @@ -17,6 +17,12 @@ function isBunCompiled(): boolean { return typeof process.execPath === 'string' && !process.execPath.includes('bun') } +function getHapiHome(): string { + return process.env.HAPI_HOME + ? process.env.HAPI_HOME.replace(/^~/, homedir()) + : join(homedir(), '.hapi') +} + function getPlatformDir(): string { const platformName = platform() const archName = arch() @@ -39,7 +45,7 @@ function getTunwgPath(): string { const tunwgBinary = isWin ? 'tunwg.exe' : 'tunwg' if (isBunCompiled()) { - const hapiHome = process.env.HAPI_HOME || join(homedir(), '.hapi') + const hapiHome = getHapiHome() const packageJson = require('../../../cli/package.json') const runtimePath = join(hapiHome, 'runtime', packageJson.version) return join(runtimePath, 'tools', 'tunwg', tunwgBinary) @@ -106,6 +112,10 @@ export class TunnelManager { const env: Record = { ...process.env as Record } + if (!env.TUNWG_PATH) { + env.TUNWG_PATH = join(getHapiHome(), 'tunwg') + } + if (this.config.apiDomain) { env.TUNWG_API = this.config.apiDomain }