From 6d1157a9d0ba0f4c26e57e07e4888fd0b44f819c Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Mon, 10 Mar 2025 16:19:04 -0500 Subject: [PATCH] refactor(server): added in ability to listen on all ip's --- server/index.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/index.ts b/server/index.ts index d5b6d77..22db8d4 100644 --- a/server/index.ts +++ b/server/index.ts @@ -15,8 +15,19 @@ import tcpServer from "./services/tcpServer/tcpServer.js"; import ocme from "./services/ocme/ocmeService.js"; import sqlService from "./services/sqlServer/sqlService.js"; import logistics from "./services/logistics/logisticsService.js"; +import {db} from "../database/dbclient.js"; +import {settings} from "../database/schema/settings.js"; +import {eq} from "drizzle-orm"; -const allowedOrigins = ["http://localhost:3000", "http://localhost:4000", "http://localhost:5173"]; +// plant token +const dbServer = await db.select().from(settings).where(eq(settings.name, "dbServer")); +const serverPort = await db.select().from(settings).where(eq(settings.name, "serverPort")); +const allowedOrigins = [ + "http://localhost:3000", + "http://localhost:4000", + "http://localhost:5173", + `http://usmcd1vms006:4000`, +]; const app = new OpenAPIHono(); // middle ware @@ -110,9 +121,10 @@ serve( { fetch: app.fetch, port: Number(process.env.VITE_SERVER_PORT), + hostname: "0.0.0.0", }, (info) => { - createLog("info", "LST", "server", `Server is running on http://localhost:${info.port}`); + createLog("info", "LST", "server", `Server is running on http://${info.address}:${info.port}`); } );