From f5c573c52f3a64537463b3c8e07d058728f046d7 Mon Sep 17 00:00:00 2001 From: Wind-Explorer Date: Mon, 1 Dec 2025 11:37:13 +0800 Subject: [PATCH] env customizable host --- .env.example | 1 + src/main.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index e419ed8..8d6b502 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ # Server Configuration +HOST="localhost" PORT=3000 NODE_ENV=development diff --git a/src/main.ts b/src/main.ts index 97c68c3..2515d0f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,13 +52,12 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('api', app, document); + const host = process.env.HOST ?? 'localhost'; const port = process.env.PORT ?? 3000; await app.listen(port); - logger.log(`Application is running on: http://localhost:${port}`); - logger.log( - `Swagger documentation available at: http://localhost:${port}/api`, - ); + logger.log(`Application is running on: http://${host}:${port}`); + logger.log(`Swagger documentation available at: http://${host}:${port}/api`); } void bootstrap();