From 529a4ff62acd0b9e9959924b0a14e300bd57ab09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=8B=AC=EC=9E=AC=EC=97=BD?= <jysim0326@ajou.ac.kr> Date: Mon, 9 Dec 2024 14:12:42 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=9B=B9=EC=86=8C=EC=BC=93=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20=EA=B2=BD=EB=A1=9C=20env=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ChattingDetail.jsx | 5 ++++- src/components/ChattingList.jsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/ChattingDetail.jsx b/src/components/ChattingDetail.jsx index a163c99..fb65a95 100644 --- a/src/components/ChattingDetail.jsx +++ b/src/components/ChattingDetail.jsx @@ -7,6 +7,9 @@ import Button from "../components/Button"; import ChattingNoticeDetailModal from '../components/ChattingNoticeDetailModal'; import ChattingNoticeListModal from '../components/ChattingNoticeListModal'; +// 웹소켓 서버 연결 URL +const WS_URL = process.env.REACT_APP_WS_URL; + // 흔들리는 애니메이션을 위한 keyframes 정의 const shakeAnimation = keyframes` 0% { transform: translateY(0); } @@ -435,7 +438,7 @@ function ChattingDetail() { ws.current.close(); // 기존 WebSocket 연결 종료 } - ws.current = new WebSocket('ws://localhost:8081'); + ws.current = new WebSocket(WS_URL); ws.current.onopen = () => { if (ws.current.isTimedOut) { console.log(`타임아웃된 클라이언트의 재연결을 차단: ${nickname}`); diff --git a/src/components/ChattingList.jsx b/src/components/ChattingList.jsx index ff4e5d1..2b278ff 100644 --- a/src/components/ChattingList.jsx +++ b/src/components/ChattingList.jsx @@ -2,6 +2,9 @@ import React, { useState, useEffect, useRef, useCallback } from "react"; import { useNavigate } from "react-router-dom"; import useAuthStore from "../store/authStore"; +// 웹소켓 서버 연결 URL +const WS_URL = process.env.REACT_APP_WS_URL; + function ChattingList() { const [rooms, setRooms] = useState([]); const [joinedRooms, setJoinedRooms] = useState([]); @@ -13,7 +16,7 @@ function ChattingList() { // WebSocket 연결 및 실시간 업데이트 const setupWebSocket = () => { - ws.current = new WebSocket('ws://localhost:8081'); // WebSocket 연결 + ws.current = new WebSocket(WS_URL); // WebSocket 연결 ws.current.onopen = () => { console.log('WebSocket 연결 성공'); -- GitLab