fix: ensure GoogleOAuthProvider is always available to prevent context errors

- Update providers to always render GoogleOAuthProvider with dummy ID when not configured
- This prevents "must be used within GoogleOAuthProvider" errors during SSR
- The login page still checks for valid client ID before showing Google button
- Fixes dev mode errors and ensures consistent behavior

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
soufiane 2025-11-18 20:10:25 +01:00
parent 935258a54a
commit 660bf32fdc

View File

@ -5,21 +5,15 @@ import { AuthProvider } from "@/contexts/AuthContext";
import { ReactNode } from "react";
export function Providers({ children }: { children: ReactNode }) {
const googleClientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || '';
// Use a dummy client ID if not provided to prevent context errors
// The actual authentication will still check for a valid ID
const googleClientId = process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID || 'dummy-client-id-not-configured';
const content = (
<AuthProvider>
{children}
</AuthProvider>
return (
<GoogleOAuthProvider clientId={googleClientId}>
<AuthProvider>
{children}
</AuthProvider>
</GoogleOAuthProvider>
);
if (googleClientId) {
return (
<GoogleOAuthProvider clientId={googleClientId}>
{content}
</GoogleOAuthProvider>
);
}
return content;
}