From 2f928579f96d2a2edff291dbcb5b2c0d98d8714c Mon Sep 17 00:00:00 2001 From: Radiquum Date: Tue, 8 Jul 2025 16:26:28 +0500 Subject: [PATCH] refactor/api-prox: unhardcode HOST and PORT to ENV VARS --- api-prox/Dockerfile | 3 +-- api-prox/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/api-prox/Dockerfile b/api-prox/Dockerfile index 685c598..de0c3a1 100644 --- a/api-prox/Dockerfile +++ b/api-prox/Dockerfile @@ -13,6 +13,5 @@ COPY tsconfig.json ./ RUN mkdir -p /app/hooks EXPOSE 7001 -ENV PORT=7001 -ENV HOSTNAME="0.0.0.0" + CMD ["npm", "run", "serve"] \ No newline at end of file diff --git a/api-prox/index.ts b/api-prox/index.ts index 1cc7f7c..0fdec06 100644 --- a/api-prox/index.ts +++ b/api-prox/index.ts @@ -20,8 +20,8 @@ app.use( app.use(express.json()); app.use(express.urlencoded({ extended: true })); -const host = "0.0.0.0"; -const port = 7001; +const HOST = process.env.HOST || "0.0.0.0"; +const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 7001; let hooks: string[] = []; @@ -356,7 +356,7 @@ app.post("/*path", async (req, res) => { return; }); -app.listen(port, host, function () { +app.listen(PORT, HOST, function () { loadHooks(); - logger.info(`Server listen: http://${host}:${port}`); + logger.info(`Server listen: http://${HOST}:${PORT}`); });