This commit is contained in:
2025-04-28 02:18:59 -06:00
parent ae10c14cc8
commit 5a9a02b772
3 changed files with 45 additions and 42 deletions

View File

@ -20,7 +20,10 @@ export default function Chat() {
setUsername(`User${randomNum}`);
}
const ws = new WebSocket(`ws://${globalThis.location.host}/api/chat`);
const wsProtocol = window.location.protocol === "https:" ? "wss:" : "ws:";
const ws = new WebSocket(
`${wsProtocol}//${globalThis.location.host}/api/chat`,
);
ws.onopen = () => {
console.log("Connected to chat");