Investigate login/signup failure

Investigate and address the "Failed to fetch" error during signup and login failures.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 15:48:52 +00:00
parent f25d55690d
commit 348194ccec
5 changed files with 97 additions and 30 deletions

View File

@@ -1,7 +1,7 @@
import { supabase } from '@/lib/supabase';
import { parseResponse, showAuthToast, handleNetworkError } from '@/utils/auth';
import { getProxyType, isCorsProxyEnabled } from '@/lib/supabase/config';
import { getProxyType, isCorsProxyEnabled, getSupabaseUrl, getOriginalSupabaseUrl } from '@/lib/supabase/config';
/**
* 직접 API 호출을 통한 로그인 시도 (대체 방법)
@@ -11,23 +11,27 @@ export const signInWithDirectApi = async (email: string, password: string) => {
try {
// API 호출 URL 및 헤더 설정
const supabaseUrl = localStorage.getItem('supabase_url') || 'https://a11.ism.kr';
const supabaseUrl = getOriginalSupabaseUrl(); // 원본 URL 사용
const proxyUrl = getSupabaseUrl(); // 프록시 적용된 URL
const supabaseKey = localStorage.getItem('supabase_key') || supabase.supabaseKey;
// 프록시 정보 로그
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
console.log(`CORS 프록시 사용: ${usingProxy ? '예' : '아니오'}, 타입: ${proxyType}`);
console.log(`CORS 프록시 사용: ${usingProxy ? '예' : '아니오'}, 타입: ${proxyType}, 프록시 URL: ${proxyUrl}`);
// 실제 요청에 사용할 URL 결정 (항상 프록시 URL 사용)
const useUrl = usingProxy ? proxyUrl : supabaseUrl;
// URL에 auth/v1이 이미 포함되어있는지 확인
const baseUrl = supabaseUrl.includes('/auth/v1') ? supabaseUrl : `${supabaseUrl}/auth/v1`;
const baseUrl = useUrl.includes('/auth/v1') ? useUrl : `${useUrl}/auth/v1`;
// 토큰 엔드포인트 경로 (curl 테스트와 동일한 형식으로)
// 토큰 엔드포인트 경로
const tokenUrl = `${baseUrl}/token?grant_type=password`;
console.log('로그인 API 요청 URL:', tokenUrl);
// 로그인 요청 보내기 (curl 테스트와 동일한 형식으로)
// 로그인 요청 보내기
const response = await fetch(tokenUrl, {
method: 'POST',
headers: {