Fix signup redirect URL

The signup redirect URL was incorrect, leading to issues with email verification. This commit fixes the URL to ensure proper redirection after signup.
This commit is contained in:
gpt-engineer-app[bot]
2025-03-15 16:15:59 +00:00
parent 4d094fbaa8
commit 7024c6423f
2 changed files with 20 additions and 5 deletions

View File

@@ -22,6 +22,12 @@ export const signUp = async (email: string, password: string, username: string)
return { error: { message: 'Supabase 설정이 올바르지 않습니다. 설정 페이지에서 확인해주세요.' }, user: null };
}
// 현재 브라우저 URL 가져오기 (localhost 대신 실제 도메인 사용)
const currentUrl = window.location.origin;
const redirectUrl = `${currentUrl}/login`;
console.log('이메일 인증 리디렉션 URL:', redirectUrl);
// 기본 회원가입 시도
try {
const { data, error } = await supabase.auth.signUp({
@@ -31,7 +37,7 @@ export const signUp = async (email: string, password: string, username: string)
data: {
username, // 사용자 이름을 메타데이터에 저장
},
emailRedirectTo: window.location.origin + '/login' // 이메일 인증 완료 후 리디렉션 URL
emailRedirectTo: redirectUrl // 현재 도메인 기반 리디렉션 URL 사용
}
});
@@ -45,7 +51,9 @@ export const signUp = async (email: string, password: string, username: string)
error.message.includes('Not Found') ||
error.message.includes('Failed to fetch')) {
console.warn('기본 회원가입 실패, 직접 API 호출 시도:', error.message);
return await signUpWithDirectApi(email, password, username);
// 직접 API 호출에도 현재 도메인 기반 리디렉션 URL 전달
return await signUpWithDirectApi(email, password, username, redirectUrl);
}
// 401 오류 감지 및 처리
@@ -120,7 +128,9 @@ export const signUp = async (email: string, password: string, username: string)
error.message.includes('timed out') ||
error.message.includes('Failed to fetch'))) {
console.warn('직접 API 호출로 재시도:', error);
return await signUpWithDirectApi(email, password, username);
// 현재 도메인 기반 리디렉션 URL 전달
return await signUpWithDirectApi(email, password, username, redirectUrl);
}
// 기타 예외 처리

View File

@@ -6,7 +6,7 @@ import { getProxyType, isCorsProxyEnabled, getSupabaseUrl, getOriginalSupabaseUr
/**
* 직접 API 호출을 통한 회원가입
*/
export const signUpWithDirectApi = async (email: string, password: string, username: string) => {
export const signUpWithDirectApi = async (email: string, password: string, username: string, redirectUrl?: string) => {
try {
console.log('직접 API 호출로 회원가입 시도 중');
@@ -24,6 +24,10 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
};
}
// 리디렉션 URL 설정 (전달되지 않은 경우 기본값 사용)
const finalRedirectUrl = redirectUrl || `${window.location.origin}/login`;
console.log('이메일 인증 리디렉션 URL (API):', finalRedirectUrl);
// 프록시 정보 로깅
const usingProxy = isCorsProxyEnabled();
const proxyType = getProxyType();
@@ -51,7 +55,8 @@ export const signUpWithDirectApi = async (email: string, password: string, usern
body: JSON.stringify({
email,
password,
data: { username } // 사용자 메타데이터에 username 추가
data: { username }, // 사용자 메타데이터에 username 추가
redirect_to: finalRedirectUrl // 리디렉션 URL 추가
}),
signal: AbortSignal.timeout(15000) // 타임아웃 시간 증가
});