diff --git a/client/src/hooks/useGameshowcase.ts b/client/src/hooks/useGameshowcase.ts index ca0a96b..fc515a9 100644 --- a/client/src/hooks/useGameshowcase.ts +++ b/client/src/hooks/useGameshowcase.ts @@ -26,21 +26,10 @@ type UiShowcaseGame = Omit & { gameCover: string; }; -function getGameCoverUrl( - game_cover_thumbnail: string | null | undefined, -): string { - if (!game_cover_thumbnail) return "/game_dev_club_logo.svg"; - if (game_cover_thumbnail.startsWith("http")) return game_cover_thumbnail; - // Use environment variable for Django backend base URL - const apiBaseUrl = - process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"; - return `${apiBaseUrl}${game_cover_thumbnail}`; -} - function transformApiShowcaseGameToUi(data: ApiShowcaseGame): UiShowcaseGame { return { ...data, - gameCover: getGameCoverUrl(data.game_cover_thumbnail), + gameCover: data.game_cover_thumbnail ?? "/game_dev_club_logo.svg", }; } diff --git a/server/game_dev/views.py b/server/game_dev/views.py index 086119c..ce665bf 100644 --- a/server/game_dev/views.py +++ b/server/game_dev/views.py @@ -66,7 +66,7 @@ def get_queryset(self): class GameshowcaseAPIView(APIView): def get(self, request): showcases = GameShowcase.objects.all() - serializer = GameshowcaseSerializer(showcases, many=True) + serializer = GameshowcaseSerializer(showcases, many=True, context={'request': request}) return Response(serializer.data)