From 648613e24c8afe5fd3c599def61b33ccf7bcb96c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 29 Jul 2024 20:04:03 +0900 Subject: feat: authenticate WebSocket connection by short-lived access token --- frontend/app/components/GolfWatchApp.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'frontend/app/components/GolfWatchApp.tsx') diff --git a/frontend/app/components/GolfWatchApp.tsx b/frontend/app/components/GolfWatchApp.tsx index bcd1f0f..00ad005 100644 --- a/frontend/app/components/GolfWatchApp.tsx +++ b/frontend/app/components/GolfWatchApp.tsx @@ -14,12 +14,18 @@ type Problem = components["schemas"]["Problem"]; type GameState = "connecting" | "waiting" | "starting" | "gaming" | "finished"; -export default function GolfWatchApp({ game }: { game: Game }) { - // const socketUrl = `wss://t.nil.ninja/iosdc/2024/sock/golf/${game.game_id}/play`; +export default function GolfWatchApp({ + game, + sockToken, +}: { + game: Game; + sockToken: string; +}) { + // const socketUrl = `wss://t.nil.ninja/iosdc/2024/sock/golf/${game.game_id}/watch?token=${sockToken}`; const socketUrl = process.env.NODE_ENV === "development" - ? `ws://localhost:8002/sock/golf/${game.game_id}/play` - : `ws://api-server/sock/golf/${game.game_id}/play`; + ? `ws://localhost:8002/sock/golf/${game.game_id}/watch?token=${sockToken}` + : `ws://api-server/sock/golf/${game.game_id}/watch?token=${sockToken}`; const { lastJsonMessage, readyState } = useWebSocket( socketUrl, -- cgit v1.2.3-70-g09d2