Address error condition
The code has an error that needs to be addressed.
This commit is contained in:
@@ -41,6 +41,19 @@ try {
|
||||
// 온프레미스 설치를 위한 추가 설정
|
||||
flowType: 'implicit',
|
||||
},
|
||||
global: {
|
||||
fetch: (...args) => {
|
||||
// CORS 디버깅을 위한 사용자 정의 fetch
|
||||
console.log('Supabase fetch 요청:', args[0]);
|
||||
return fetch(...args).then(response => {
|
||||
console.log('Supabase 응답 상태:', response.status);
|
||||
return response;
|
||||
}).catch(err => {
|
||||
console.error('Supabase fetch 오류:', err);
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// CORS 문제 확인을 위한 기본 헤더 테스트
|
||||
@@ -59,7 +72,14 @@ try {
|
||||
if (response.ok) {
|
||||
console.log('Supabase REST API 연결 성공:', response.status);
|
||||
} else {
|
||||
console.warn('Supabase REST API 연결 실패:', response.status);
|
||||
console.warn('Supabase REST API 연결 실패:', response.status, response.statusText);
|
||||
// 응답 세부 정보 로깅
|
||||
try {
|
||||
const errorText = await response.text();
|
||||
console.warn('Supabase REST API 오류 응답:', errorText);
|
||||
} catch (e) {
|
||||
console.error('응답 내용 읽기 실패:', e);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Supabase 서버 상태 확인 중 오류 (CORS 문제 가능성):', err);
|
||||
@@ -175,6 +195,7 @@ export const testSupabaseConnection = async () => {
|
||||
try {
|
||||
// 1. REST API 접근 테스트
|
||||
try {
|
||||
console.log('REST API 테스트 시작...');
|
||||
const response = await fetch(`${supabaseUrl}/rest/v1/`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -185,25 +206,36 @@ export const testSupabaseConnection = async () => {
|
||||
|
||||
results.restApi = response.ok;
|
||||
if (!response.ok) {
|
||||
results.errors.push(`REST API 오류: ${response.status} ${response.statusText}`);
|
||||
const errorBody = await response.text();
|
||||
results.errors.push(`REST API 오류(${response.status} ${response.statusText}): ${errorBody || '응답 없음'}`);
|
||||
console.error('REST API 테스트 실패:', response.status, errorBody);
|
||||
} else {
|
||||
console.log('REST API 테스트 성공');
|
||||
}
|
||||
} catch (err: any) {
|
||||
results.errors.push(`REST API 예외: ${err.message}`);
|
||||
results.errors.push(`REST API 예외: ${err.message || '알 수 없는 오류'}`);
|
||||
console.error('REST API 테스트 중 예외:', err);
|
||||
}
|
||||
|
||||
// 2. 인증 서비스 테스트
|
||||
try {
|
||||
console.log('인증 서비스 테스트 시작...');
|
||||
const { data, error } = await supabaseClient.auth.getSession();
|
||||
results.auth = !error;
|
||||
if (error) {
|
||||
results.errors.push(`인증 오류: ${error.message}`);
|
||||
console.error('인증 테스트 실패:', error);
|
||||
} else {
|
||||
console.log('인증 테스트 성공');
|
||||
}
|
||||
} catch (err: any) {
|
||||
results.errors.push(`인증 예외: ${err.message}`);
|
||||
results.errors.push(`인증 예외: ${err.message || '알 수 없는 오류'}`);
|
||||
console.error('인증 테스트 중 예외:', err);
|
||||
}
|
||||
|
||||
// 3. 데이터베이스 연결 테스트
|
||||
try {
|
||||
console.log('데이터베이스 연결 테스트 시작...');
|
||||
const { data, error } = await supabaseClient
|
||||
.from('transactions')
|
||||
.select('*')
|
||||
@@ -212,12 +244,22 @@ export const testSupabaseConnection = async () => {
|
||||
results.database = !error;
|
||||
if (error) {
|
||||
results.errors.push(`데이터베이스 오류: ${error.message}`);
|
||||
console.error('데이터베이스 테스트 실패:', error);
|
||||
} else {
|
||||
console.log('데이터베이스 테스트 성공', data);
|
||||
}
|
||||
} catch (err: any) {
|
||||
results.errors.push(`데이터베이스 예외: ${err.message}`);
|
||||
results.errors.push(`데이터베이스 예외: ${err.message || '알 수 없는 오류'}`);
|
||||
console.error('데이터베이스 테스트 중 예외:', err);
|
||||
}
|
||||
|
||||
// 오류가 없는 경우 메시지 추가
|
||||
if (results.errors.length === 0) {
|
||||
results.errors.push('모든 테스트 통과! 연결 상태가 정상입니다.');
|
||||
}
|
||||
} catch (err: any) {
|
||||
results.errors.push(`테스트 실행 예외: ${err.message}`);
|
||||
results.errors.push(`테스트 실행 예외: ${err.message || '알 수 없는 오류'}`);
|
||||
console.error('전체 테스트 실행 중 예외:', err);
|
||||
}
|
||||
|
||||
console.log('Supabase 연결 테스트 결과:', results);
|
||||
|
||||
Reference in New Issue
Block a user