From ff5c5f1b1d0ba9c653f689a32782044a2d36a843 Mon Sep 17 00:00:00 2001 From: Nik Afiq Date: Thu, 11 Dec 2025 22:22:40 +0900 Subject: [PATCH] feat(auth): improve error handling for popup-blocked sign-in attempts --- frontend/src/auth/AuthProvider.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/frontend/src/auth/AuthProvider.tsx b/frontend/src/auth/AuthProvider.tsx index a244155..07fe229 100644 --- a/frontend/src/auth/AuthProvider.tsx +++ b/frontend/src/auth/AuthProvider.tsx @@ -78,17 +78,12 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { try { await signInWithPopup(auth, provider); } catch (err: any) { + // Avoid redirect fallback to prevent navigation/404; surface a clearer popup-blocked message. const code = err?.code ?? ""; - // Common cases where redirect works better - const redirectable = [ - "auth/popup-blocked", - "auth/operation-not-supported-in-this-environment", - "auth/unauthorized-domain", - ]; - if (redirectable.includes(code)) { - const { signInWithRedirect } = await import("firebase/auth"); - await signInWithRedirect(auth, provider); - return; // navigation will happen + if (code === "auth/popup-blocked") { + setError("ポップアップがブロックされました。ブラウザで許可してください。"); + console.error("signin popup blocked:", err); + return; } const msg = err instanceof Error ? err.message : String(err); setError(msg); // keep the message for the UI