fix websocket

This commit is contained in:
2026-02-03 09:42:51 -05:00
parent 45d88d9f0c
commit c336fe8b96
2 changed files with 8 additions and 2 deletions

View File

@@ -123,7 +123,9 @@ setInterval(() => {
}, 100)
function createSession() {
store.connect(`ws://${window.location.hostname}:8000/ws/host`)
const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
const port = window.location.port
store.connect(`${proto}//${window.location.hostname}:${port}/ws/host`)
store.ws.onopen = () => {
const quiz = yaml.load(yamlInput.value)
store.send({ action: 'CREATE_SESSION', quiz })

View File

@@ -77,7 +77,11 @@ const myScore = computed(() => {
})
function joinGame() {
store.connect(`ws://${window.location.hostname}:8000/ws/play/${code.value}/${name.value}`)
const proto = window.location.protocol === 'https:' ? 'wss:' : 'ws:'
const port = window.location.port
store.connect(
`${proto}://${window.location.hostname}:${port}/ws/play/${code.value}/${name.value}`,
)
store.ws.onopen = () => {
joined.value = true
// If we join mid-game, this ensures we see the right state