From 814d68c215531bd21d95e2366786ab9e7e56a19c Mon Sep 17 00:00:00 2001 From: MartinFillon Date: Tue, 17 Feb 2026 20:56:57 +0100 Subject: [PATCH] feat(client): add tls options for https --- apps/client/src/env.ts | 10 ++++++++++ apps/client/src/server.ts | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/apps/client/src/env.ts b/apps/client/src/env.ts index f38666c..9502545 100644 --- a/apps/client/src/env.ts +++ b/apps/client/src/env.ts @@ -14,6 +14,16 @@ export const getGameDir = () => { throw new Error("GAME_DIR env variable not found"); }; +export const getCert = () => { + if (process.env.CERT) return process.env.CERT; + else return undefined; +}; + +export const getKey = () => { + if (process.env.KEY) return process.env.KEY; + else return undefined; +}; + export const getWatch = () => { return process.env.WATCH; }; diff --git a/apps/client/src/server.ts b/apps/client/src/server.ts index dad72fe..6805148 100644 --- a/apps/client/src/server.ts +++ b/apps/client/src/server.ts @@ -1,7 +1,9 @@ import { join } from "node:path"; import { + getCert, getGameDir, + getKey, getPort, getPublicEnv, getWatch, @@ -40,8 +42,14 @@ const headers = { "Access-Control-Allow-Methods": "GET", }; +const cert = getCert(); +const key = getKey(); + +const tls = cert && key ? { cert: Bun.file(cert), key: Bun.file(key) } : undefined; + const server = Bun.serve({ port: port, + tls: tls, routes: { "/": () => { const file = Bun.file(resolveWebDir("index.html"));