Refactor: Improve code organization

Refactor signInUtils.ts and networkUtils.ts into smaller, more manageable files.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-18 06:18:00 +00:00
parent 609c6703cc
commit 6861f4d88b
10 changed files with 245 additions and 214 deletions

View File

@@ -0,0 +1,64 @@
import { getSupabaseUrl } from '@/lib/supabase/config';
/**
* 강화된 서버 연결 검사 - Supabase Cloud 환경에 최적화
*/
export const verifySupabaseConnection = async (): Promise<{
connected: boolean;
message: string;
statusCode?: number;
details?: string;
}> => {
const supabaseUrl = getSupabaseUrl();
if (!supabaseUrl) {
return {
connected: false,
message: 'Supabase URL이 설정되지 않았습니다'
};
}
// 무작위 쿼리 파라미터를 추가하여 캐시 방지
const cacheParam = `?_nocache=${Date.now()}`;
// 다양한 경로를 순차적으로 시도
const paths = [
'/auth/v1/',
'/',
'/rest/v1/',
'/storage/v1/'
];
for (const path of paths) {
try {
console.log(`경로 시도: ${path}`);
const response = await fetch(`${supabaseUrl}${path}${cacheParam}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
signal: AbortSignal.timeout(8000)
});
console.log(`경로 ${path} 응답 상태:`, response.status);
// 어떤 응답이든 서버가 살아있다는 신호로 간주
return {
connected: true,
message: `서버 연결 성공 (${path})`,
statusCode: response.status,
details: `${response.status} ${response.statusText}`
};
} catch (error) {
console.warn(`${path} 경로 연결 실패:`, error);
// 계속 다음 경로 시도
}
}
// 모든 경로 시도 실패
return {
connected: false,
message: '모든 Supabase 경로에 대한 연결 시도 실패',
details: '네트워크 연결 또는 서버 주소를 확인하세요'
};
};