From 8d2720e18181f5a938f45dfd17e9c33123311fd2 Mon Sep 17 00:00:00 2001 From: Sukyeong Sung Date: Mon, 10 Mar 2025 12:18:35 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20s3=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 ++- src/components/ChatRoomList.jsx | 27 ++++++++++++++++----------- src/config.js | 10 +++++++--- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.env b/.env index 0c6fdce..abf0f10 100644 --- a/.env +++ b/.env @@ -1,2 +1,3 @@ VITE_CORE_FRONT_BASE_URL="http://localhost:5173" -VITE_CORE_API_BASE_URL="http://localhost:8090" \ No newline at end of file +VITE_CORE_API_BASE_URL="http://localhost:8090" +REACT_APP_API_URL=http://localhost:8090 \ No newline at end of file diff --git a/src/components/ChatRoomList.jsx b/src/components/ChatRoomList.jsx index 4cdbf92..d1f66df 100644 --- a/src/components/ChatRoomList.jsx +++ b/src/components/ChatRoomList.jsx @@ -4,7 +4,6 @@ import ChatService from '../services/ChatService'; import ChatRoom from './ChatRoom'; import PasswordModal from './PasswordModal'; import './ChatStyles.css'; -import { API_BACKEND_URL } from '../config'; import { Home } from 'lucide-react'; // Import Home icon from lucide-react const ChatRoomList = () => { @@ -263,13 +262,16 @@ const ChatRoomList = () => { const isRoomsEmpty = rooms.length === 0; const getImageUrl = (imageUrl) => { - if (!imageUrl) return null; - console.log('Original imageUrl:', imageUrl); // 디버깅용 - // API_BACKEND_URL이 이미 슬래시로 끝나지 않는지 확인 - const baseUrl = API_BACKEND_URL.endsWith('/') ? API_BACKEND_URL.slice(0, -1) : API_BACKEND_URL; - const fullUrl = `${baseUrl}${imageUrl}`; - console.log('Full imageUrl:', fullUrl); // 디버깅용 - return fullUrl; + if (!imageUrl) return '/default-room.png'; + try { + // 이미 완전한 S3 URL인 경우 그대로 반환 + if (imageUrl.includes('s3.ap-northeast-2.amazonaws.com')) { + return imageUrl; + } + return '/default-room.png'; + } catch { + return '/default-room.png'; + } }; return ( @@ -345,10 +347,13 @@ const ChatRoomList = () => { src={getImageUrl(room.imageUrl)} alt={room.title} className="room-image" + loading="lazy" onError={(e) => { - console.log('Image load failed:', room.imageUrl); - e.target.onerror = null; - e.target.src = '/default-room.png'; + if (!e.target.getAttribute('data-error-handled')) { + console.error('Image load failed:', room.imageUrl); + e.target.setAttribute('data-error-handled', 'true'); + e.target.src = '/default-room.png'; + } }} /> ) : ( diff --git a/src/config.js b/src/config.js index 74c4773..e2723db 100644 --- a/src/config.js +++ b/src/config.js @@ -1,4 +1,8 @@ -const API_BACKEND_URL = import.meta.env.VITE_CORE_API_BASE_URL; -const API_FRONT_URL = import.meta.env.VITE_CORE_FRONT_BASE_URL; +// Vite 환경변수 사용 +const API_BACKEND_URL = import.meta.env.VITE_CORE_API_BASE_URL || 'http://localhost:8090'; +const API_FRONT_URL = import.meta.env.VITE_CORE_FRONT_BASE_URL || 'http://localhost:5173'; -export { API_BACKEND_URL, API_FRONT_URL }; \ No newline at end of file +export { + API_BACKEND_URL, + API_FRONT_URL +}; \ No newline at end of file