@@ -4,7 +4,6 @@ import ChatService from '../services/ChatService';
44import ChatRoom from './ChatRoom' ;
55import PasswordModal from './PasswordModal' ;
66import './ChatStyles.css' ;
7- import { API_BACKEND_URL } from '../config' ;
87import { Home } from 'lucide-react' ; // Import Home icon from lucide-react
98
109const ChatRoomList = ( ) => {
@@ -263,13 +262,16 @@ const ChatRoomList = () => {
263262 const isRoomsEmpty = rooms . length === 0 ;
264263
265264 const getImageUrl = ( imageUrl ) => {
266- if ( ! imageUrl ) return null ;
267- console . log ( 'Original imageUrl:' , imageUrl ) ; // 디버깅용
268- // API_BACKEND_URL이 이미 슬래시로 끝나지 않는지 확인
269- const baseUrl = API_BACKEND_URL . endsWith ( '/' ) ? API_BACKEND_URL . slice ( 0 , - 1 ) : API_BACKEND_URL ;
270- const fullUrl = `${ baseUrl } ${ imageUrl } ` ;
271- console . log ( 'Full imageUrl:' , fullUrl ) ; // 디버깅용
272- return fullUrl ;
265+ if ( ! imageUrl ) return '/default-room.png' ;
266+ try {
267+ // 이미 완전한 S3 URL인 경우 그대로 반환
268+ if ( imageUrl . includes ( 's3.ap-northeast-2.amazonaws.com' ) ) {
269+ return imageUrl ;
270+ }
271+ return '/default-room.png' ;
272+ } catch {
273+ return '/default-room.png' ;
274+ }
273275 } ;
274276
275277 return (
@@ -345,10 +347,13 @@ const ChatRoomList = () => {
345347 src = { getImageUrl ( room . imageUrl ) }
346348 alt = { room . title }
347349 className = "room-image"
350+ loading = "lazy"
348351 onError = { ( e ) => {
349- console . log ( 'Image load failed:' , room . imageUrl ) ;
350- e . target . onerror = null ;
351- e . target . src = '/default-room.png' ;
352+ if ( ! e . target . getAttribute ( 'data-error-handled' ) ) {
353+ console . error ( 'Image load failed:' , room . imageUrl ) ;
354+ e . target . setAttribute ( 'data-error-handled' , 'true' ) ;
355+ e . target . src = '/default-room.png' ;
356+ }
352357 } }
353358 />
354359 ) : (
0 commit comments