From b25add0cff89af4499bb1f1d3aaee2e04a0f0ad8 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 15 Mar 2025 06:37:02 +0000 Subject: [PATCH] Investigate Supabase API key issue The prompt indicates a problem with the Supabase API key, so this commit investigates and addresses the issue. --- .env | 4 +- src/components/SupabaseTestPanel.tsx | 27 ++++++++-- src/utils/supabaseTest.ts | 73 +++++++++++++++++----------- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/.env b/.env index abedadd..f192697 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -VITE_SUPABASE_URL=https://xguihxuzqibwxjnimxev.supabase.co -VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhndWloeHV6cWlid3hqbmlteGV2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzUwOTQ4MzUsImV4cCI6MTk5MDY3MDgzNX0.0PMlOxtKL4O9GGZuAP_Xl4f-Tut1qOnW4bNEmAtoB8w +VITE_SUPABASE_URL=your_supabase_url_here +VITE_SUPABASE_ANON_KEY=your_supabase_anon_key_here diff --git a/src/components/SupabaseTestPanel.tsx b/src/components/SupabaseTestPanel.tsx index e680612..be977e0 100644 --- a/src/components/SupabaseTestPanel.tsx +++ b/src/components/SupabaseTestPanel.tsx @@ -1,14 +1,15 @@ import React, { useState } from 'react'; import { Button } from '@/components/ui/button'; -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; +import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; -import { CircleCheck, CircleAlert, RefreshCw, Database } from 'lucide-react'; +import { CircleCheck, CircleAlert, RefreshCw, Database, AlertCircle } from 'lucide-react'; import { testSupabaseConnection, checkSupabaseEnvironment, checkSupabaseTables } from '@/utils/supabaseTest'; +import { Alert, AlertDescription } from '@/components/ui/alert'; const SupabaseTestPanel = () => { const [loading, setLoading] = useState(false); @@ -62,8 +63,22 @@ const SupabaseTestPanel = () => { Supabase 연결 테스트 + + 백엔드 서비스 연결 상태를 확인합니다 + + {/* 환경 변수 설정이 잘못된 경우 경고 표시 */} + {!envStatus.valid && ( + + + +

환경 변수 설정이 필요합니다

+

.env 파일을 업데이트하여 Supabase URL과 API 키를 설정해주세요.

+
+
+ )} + {/* 환경 변수 상태 */}
환경 변수 설정 @@ -137,12 +152,18 @@ const SupabaseTestPanel = () => { + + {!envStatus.valid && ( +

+ 테스트를 실행하기 전에 먼저 .env 파일을 업데이트해주세요. +

+ )} ); diff --git a/src/utils/supabaseTest.ts b/src/utils/supabaseTest.ts index 661e1c2..e2e4e85 100644 --- a/src/utils/supabaseTest.ts +++ b/src/utils/supabaseTest.ts @@ -2,11 +2,49 @@ import { supabase } from '@/lib/supabase'; import { toast } from '@/components/ui/use-toast'; +/** + * Supabase 환경 설정 확인 + * 환경 변수가 올바르게 설정되었는지 확인합니다. + */ +export const checkSupabaseEnvironment = (): { valid: boolean; message: string } => { + const supabaseUrl = import.meta.env.VITE_SUPABASE_URL; + const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY; + + if (!supabaseUrl || !supabaseAnonKey) { + return { + valid: false, + message: '환경 변수가 설정되지 않았습니다.' + }; + } + + if (supabaseUrl.includes('your_supabase_url_here') || + supabaseAnonKey.includes('your_supabase_anon_key_here')) { + return { + valid: false, + message: '환경 변수가 아직 실제 값으로 설정되지 않았습니다. .env 파일을 업데이트해주세요.' + }; + } + + return { + valid: true, + message: '환경 변수가 올바르게 설정되었습니다.' + }; +}; + /** * Supabase 연결 테스트 * 현재 Supabase 연결 상태를 확인합니다. */ export const testSupabaseConnection = async (): Promise<{ success: boolean; message: string }> => { + // 먼저 환경 설정 확인 + const envCheck = checkSupabaseEnvironment(); + if (!envCheck.valid) { + return { + success: false, + message: `환경 설정 오류: ${envCheck.message}` + }; + } + try { // 서버에 핑 보내기 const { data, error } = await supabase.from('_ping').select('*').limit(1); @@ -68,6 +106,12 @@ export const runSupabaseConnectionTest = async () => { * 지정된 테이블이 존재하는지 확인합니다. */ export const checkSupabaseTables = async (): Promise<{ exists: boolean; tables: string[] }> => { + // 먼저 환경 설정 확인 + const envCheck = checkSupabaseEnvironment(); + if (!envCheck.valid) { + return { exists: false, tables: [] }; + } + try { // 현재 스키마의 테이블 목록 가져오기 const { data, error } = await supabase @@ -95,32 +139,3 @@ export const checkSupabaseTables = async (): Promise<{ exists: boolean; tables: return { exists: false, tables: [] }; } }; - -/** - * Supabase 환경 설정 확인 - * 환경 변수가 올바르게 설정되었는지 확인합니다. - */ -export const checkSupabaseEnvironment = (): { valid: boolean; message: string } => { - const supabaseUrl = import.meta.env.VITE_SUPABASE_URL; - const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY; - - if (!supabaseUrl || !supabaseAnonKey) { - return { - valid: false, - message: '환경 변수가 설정되지 않았습니다.' - }; - } - - if (supabaseUrl.includes('YOUR_SUPABASE_URL') || - supabaseAnonKey.includes('YOUR_SUPABASE_ANON_KEY')) { - return { - valid: false, - message: '환경 변수가 기본값으로 설정되어 있습니다.' - }; - } - - return { - valid: true, - message: '환경 변수가 올바르게 설정되었습니다.' - }; -};