Add domain config

This commit is contained in:
tedspare
2024-03-19 22:27:58 -04:00
parent 60b3960f52
commit ba1b5ec6a1
2 changed files with 10 additions and 5 deletions
+3 -1
View File
@@ -5,6 +5,8 @@ type Client = { id: string };
const port = 1234;
const protocol = "http";
const domain = Bun.env.DOMAIN || `localhost:${port}`;
console.log("domain:", domain);
const clients = new Map<string, ServerWebSocket<Client>>();
const clientData = new Map<string, any>();
@@ -60,7 +62,7 @@ serve<Client>({
ws.send(
JSON.stringify({
id: ws.data.id,
url: `${protocol}://${ws.data.id}.localhost:${port}`,
url: `${protocol}://${ws.data.id}.${domain}`,
})
);
},