Investigate Supabase API key issue

The prompt indicates a problem with the Supabase API key, so this commit investigates and addresses the issue.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 06:37:02 +00:00
parent df24e545e2
commit b25add0cff
3 changed files with 70 additions and 34 deletions

View File

@@ -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: '환경 변수가 올바르게 설정되었습니다.'
};
};