diff --git a/src/app/room/[code]/page.tsx b/src/app/room/[code]/page.tsx index f60ddab..0f993f6 100644 --- a/src/app/room/[code]/page.tsx +++ b/src/app/room/[code]/page.tsx @@ -58,8 +58,20 @@ export default function RoomPage() { const roomData = await res.json(); setRoom(roomData); - // If authenticated user is host and no token yet, fetch host token + // If authenticated user is host and no token yet if (!token && userId && roomData.hostId === userId) { + // Auto-start room if still WAITING + if (roomData.status === "WAITING") { + const startRes = await fetch(`/api/rooms/${roomData.id}/start`, { + method: "POST", + }); + if (startRes.ok) { + const startedRoom = await startRes.json(); + setRoom({ ...roomData, status: startedRoom.status }); + } + } + + // Now fetch token const tokenRes = await fetch("/api/livekit/token", { method: "POST", headers: { "Content-Type": "application/json" },