Investigate login/register 404 errors

Investigate and address persistent 404 errors occurring during login and registration processes.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 15:01:48 +00:00
parent a32eb26105
commit e52ca26cef
7 changed files with 223 additions and 75 deletions

View File

@@ -13,7 +13,8 @@ export const signIn = async (email: string, password: string) => {
// 서버 연결 상태 먼저 확인
const connectionStatus = await verifyServerConnection();
if (!connectionStatus.connected) {
showAuthToast('서버 연결 실패', connectionStatus.message, 'destructive');
console.log('서버 연결 실패, 오프라인 모드 활성화를 고려하세요.');
showAuthToast('서버 연결 실패', `${connectionStatus.message} (오프라인 모드를 사용해보세요)`, 'destructive');
return {
error: { message: `서버 연결에 실패했습니다: ${connectionStatus.message}` },
user: null
@@ -33,8 +34,13 @@ export const signIn = async (email: string, password: string) => {
showAuthToast('로그인 성공', '환영합니다!');
return { error: null, user: data.user };
} else if (error) {
// JSON 파싱 오류인 경우 직접 API 호출 시도
if (error.message.includes('json') || error.message.includes('Unexpected end')) {
console.error('로그인 오류:', error.message);
// REST API 오류인 경우 직접 API 호출 시도
if (error.message.includes('json') ||
error.message.includes('Unexpected end') ||
error.message.includes('404') ||
error.message.includes('Not Found')) {
console.warn('기본 로그인 실패, 직접 API 호출 시도:', error.message);
return await signInWithDirectApi(email, password);
} else {
@@ -51,8 +57,17 @@ export const signIn = async (email: string, password: string) => {
return { error: { message: errorMessage }, user: null };
}
}
} catch (basicAuthError) {
} catch (basicAuthError: any) {
console.warn('기본 인증 방식 예외 발생:', basicAuthError);
// 404 에러나 경로 오류인 경우에도 직접 API 호출 시도
if (basicAuthError.message && (
basicAuthError.message.includes('404') ||
basicAuthError.message.includes('Not Found')
)) {
return await signInWithDirectApi(email, password);
}
// 기본 로그인 실패 시 아래 직접 API 호출 방식 계속 진행
return await signInWithDirectApi(email, password);
}
@@ -64,7 +79,7 @@ export const signIn = async (email: string, password: string) => {
// 네트워크 오류 확인
const errorMessage = handleNetworkError(error);
showAuthToast('로그인 오류', errorMessage, 'destructive');
showAuthToast('로그인 오류', `${errorMessage} (오프라인 모드를 사용해보세요)`, 'destructive');
return { error: { message: errorMessage }, user: null };
}