fix: make dashboard locally accessible only

This commit is contained in:
syntaxbullet
2026-01-07 14:33:19 +01:00
parent 8047bce755
commit 66af870aa9
3 changed files with 6 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ const envSchema = z.object({
DISCORD_GUILD_ID: z.string().optional(),
DATABASE_URL: z.string().min(1, "Database URL is required"),
PORT: z.coerce.number().default(3000),
HOST: z.string().default("127.0.0.1"),
});
const parsedEnv = envSchema.safeParse(process.env);

View File

@@ -9,7 +9,8 @@ export class WebServer {
public static start(port?: number) {
this.server = Bun.serve({
port: port ?? (typeof env.PORT === "string" ? parseInt(env.PORT) : 3000),
port: port ?? env.PORT,
hostname: env.HOST,
fetch: (req, server) => {
const url = new URL(req.url);
if (url.pathname === "/ws") {
@@ -38,7 +39,7 @@ export class WebServer {
},
});
console.log(`🌐 Web server listening on http://localhost:${this.server.port}`);
console.log(`🌐 Web server listening on http://${this.server.hostname}:${this.server.port} (Restricted to Local Interface)`);
// Start a heartbeat loop
this.heartbeatInterval = setInterval(() => {