Debug login issues in lovable app
Investigate and address potential causes of login failures in the lovable app, including API request format discrepancies, cached token issues, and network problems.
This commit is contained in:
@@ -9,7 +9,7 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
try {
|
||||
console.log('직접 API 호출로 회원가입 시도 중');
|
||||
|
||||
const supabaseUrl = localStorage.getItem('supabase_url') || 'http://a11.ism.kr';
|
||||
const supabaseUrl = localStorage.getItem('supabase_url') || 'https://a11.ism.kr';
|
||||
const supabaseKey = localStorage.getItem('supabase_key') || supabase.supabaseKey;
|
||||
|
||||
// URL에 auth/v1이 이미 포함되어있는지 확인
|
||||
@@ -46,8 +46,23 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
};
|
||||
}
|
||||
|
||||
// 응답 처리
|
||||
const responseData = await parseResponse(response);
|
||||
// 응답 내용 가져오기
|
||||
const responseText = await response.text();
|
||||
console.log('회원가입 응답 내용:', responseText);
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
// 응답이 비어있지 않은 경우에만 JSON 파싱 시도
|
||||
responseData = responseText ? JSON.parse(responseText) : {};
|
||||
} catch (e) {
|
||||
console.warn('JSON 파싱 실패:', e, '원본 응답:', responseText);
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
// 성공 응답이지만 JSON이 아닌 경우 (빈 응답 등)
|
||||
responseData = { success: true };
|
||||
} else {
|
||||
responseData = { error: '서버 응답을 처리할 수 없습니다' };
|
||||
}
|
||||
}
|
||||
|
||||
if (responseData && responseData.error) {
|
||||
const errorMessage = responseData.error_description || responseData.error || '회원가입 실패';
|
||||
@@ -93,6 +108,14 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
|
||||
|
||||
return { error: null, user };
|
||||
}
|
||||
} else if (response.ok) {
|
||||
// 응답이 성공이지만 사용자 정보가 없는 경우
|
||||
showAuthToast('회원가입 성공', '계정이 생성되었습니다. 로그인해주세요.', 'default');
|
||||
return {
|
||||
error: null,
|
||||
user: { email },
|
||||
message: '회원가입 처리 완료'
|
||||
};
|
||||
} else {
|
||||
// 예상치 못한 응답 형식
|
||||
const errorMessage = '회원가입 처리 중 오류가 발생했습니다. 나중에 다시 시도하세요.';
|
||||
|
||||
Reference in New Issue
Block a user