From 69f8bfe874ce21184d062973fb14f71d6a683551 Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 26 Apr 2024 02:02:19 -0400 Subject: [PATCH] fix(server): default host binding (#9090) --- server/src/main.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main.ts b/server/src/main.ts index 54e6a97acc..4638df4aee 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -14,10 +14,11 @@ import { ApiService } from 'src/services/api.service'; import { otelSDK } from 'src/utils/instrumentation'; import { useSwagger } from 'src/utils/misc'; +const host = process.env.HOST; + async function bootstrapMicroservices() { otelSDK.start(); - const host = String(process.env.HOST || '0.0.0.0'); const port = Number(process.env.MICROSERVICES_PORT) || 3002; const app = await NestFactory.create(MicroservicesModule, { bufferLogs: true }); const logger = await app.resolve(ILoggerRepository); @@ -25,7 +26,7 @@ async function bootstrapMicroservices() { app.useLogger(logger); app.useWebSocketAdapter(new WebSocketAdapter(app)); - await app.listen(port, host); + await (host ? app.listen(port, host) : app.listen(port)); logger.log(`Immich Microservices is listening on ${await app.getUrl()} [v${serverVersion}] [${envName}] `); } @@ -33,7 +34,6 @@ async function bootstrapMicroservices() { async function bootstrapApi() { otelSDK.start(); - const host = String(process.env.HOST || '0.0.0.0'); const port = Number(process.env.SERVER_PORT) || 3001; const app = await NestFactory.create(ApiModule, { bufferLogs: true }); const logger = await app.resolve(ILoggerRepository); @@ -69,7 +69,7 @@ async function bootstrapApi() { } app.use(app.get(ApiService).ssr(excludePaths)); - const server = await app.listen(port, host); + const server = await (host ? app.listen(port, host) : app.listen(port)); server.requestTimeout = 30 * 60 * 1000; logger.log(`Immich Server is listening on ${await app.getUrl()} [v${serverVersion}] [${envName}] `);