Update CORS proxy configuration

This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 15:41:32 +00:00
parent 0f4f426dd4
commit 1c3c4f37e0
5 changed files with 76 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import { supabase } from '@/lib/supabase';
import { parseResponse, showAuthToast, handleNetworkError } from '@/utils/auth';
import { getProxyType, isCorsProxyEnabled } from '@/lib/supabase/config';
/**
* 직접 API 호출을 통한 로그인 시도 (대체 방법)
@@ -13,6 +14,11 @@ export const signInWithDirectApi = async (email: string, password: string) => {
const supabaseUrl = localStorage.getItem('supabase_url') || 'https://a11.ism.kr';
const supabaseKey = localStorage.getItem('supabase_key') || supabase.supabaseKey;
// 프록시 정보 로그
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
console.log(`CORS 프록시 사용: ${usingProxy ? '예' : '아니오'}, 타입: ${proxyType}`);
// URL에 auth/v1이 이미 포함되어있는지 확인
const baseUrl = supabaseUrl.includes('/auth/v1') ? supabaseUrl : `${supabaseUrl}/auth/v1`;
@@ -178,9 +184,21 @@ export const signInWithDirectApi = async (email: string, password: string) => {
} catch (fetchError) {
console.error('로그인 요청 중 fetch 오류:', fetchError);
const errorMessage = handleNetworkError(fetchError);
showAuthToast('로그인 요청 실패', errorMessage, 'destructive');
// 오류 발생 시 프록시 설정 확인 정보 출력
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
console.log(`오류 발생 시 CORS 설정 - 프록시 사용: ${usingProxy ? '예' : '아니오'}, 타입: ${proxyType}`);
return { error: { message: errorMessage }, user: null };
// Cloudflare 프록시 추천 메시지 추가
const errorMessage = handleNetworkError(fetchError);
let enhancedMessage = errorMessage;
if (!usingProxy || proxyType !== 'cloudflare') {
enhancedMessage = `${errorMessage} (설정에서 Cloudflare CORS 프록시 사용을 권장합니다)`;
}
showAuthToast('로그인 요청 실패', enhancedMessage, 'destructive');
return { error: { message: enhancedMessage }, user: null };
}
};