Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions apps/client/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
8 changes: 8 additions & 0 deletions apps/client/src/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { join } from "node:path";

import {
getCert,
getGameDir,
getKey,
getPort,
getPublicEnv,
getWatch,
Expand Down Expand Up @@ -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"));
Expand Down