From f82985f84e37eeebe91eda13c46c222fd5906132 Mon Sep 17 00:00:00 2001 From: soufiane Date: Tue, 18 Nov 2025 02:52:33 +0100 Subject: [PATCH] fix: make Google and Facebook OAuth optional to prevent errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Make GoogleOAuthProvider conditional in layout.tsx (only render if clientId exists) - Add hasGoogleAuth and hasFacebookAuth flags in login page - Conditionally render OAuth buttons and section only when configured - Add fallback message when OAuth is not configured - Prevents "Missing required parameter client_id" error when NEXT_PUBLIC_GOOGLE_CLIENT_ID is not set This allows the app to run without OAuth credentials configured, making deployment easier when OAuth is not yet set up. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/layout.tsx | 18 +++++-- app/login/page.tsx | 123 ++++++++++++++++++++++++--------------------- 2 files changed, 80 insertions(+), 61 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index 9dd45b3..9164607 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -38,12 +38,22 @@ export const metadata: Metadata = { const googleClientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || ''; export default function RootLayout({ children }: { children: React.ReactNode }) { + const content = ( + + {children} + + ); + return ( - - - {children} + {googleClientId ? ( + + {content} + + ) : ( + content + )} - - ); diff --git a/app/login/page.tsx b/app/login/page.tsx index d5ec63c..c07bafc 100644 --- a/app/login/page.tsx +++ b/app/login/page.tsx @@ -20,6 +20,9 @@ export default function LoginPage() { const [isFacebookLoading, setIsFacebookLoading] = useState(false); const [isFacebookSDKLoaded, setIsFacebookSDKLoaded] = useState(false); + const hasGoogleAuth = !!process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID; + const hasFacebookAuth = !!process.env.NEXT_PUBLIC_FACEBOOK_APP_ID; + useEffect(() => { // Initialiser le SDK Facebook au chargement de la page initFacebookSDK() @@ -51,7 +54,7 @@ export default function LoginPage() { } }; - const handleGoogleLogin = useGoogleLogin({ + const handleGoogleLogin = hasGoogleAuth ? useGoogleLogin({ onSuccess: async (tokenResponse) => { setIsGoogleLoading(true); console.log('🔑 Token Google reçu:', tokenResponse); @@ -69,7 +72,9 @@ export default function LoginPage() { }, flow: 'implicit', scope: 'openid email profile', - }); + }) : () => { + toast.error("La connexion Google n'est pas configurée"); + }; const handleFacebookLogin = async () => { if (!isFacebookSDKLoaded) { @@ -142,63 +147,69 @@ export default function LoginPage() { -
-
-
-
+ {(hasGoogleAuth || hasFacebookAuth) && ( +
+
+
+
+
+
+ + Ou continuer avec + +
-
- - Ou continuer avec - + +
+ {hasGoogleAuth && ( + + )} + + {hasFacebookAuth && ( + + )}
- -
- - - -
-
+ )}

Vous n'avez pas de compte ?{" "}