-
Notifications
You must be signed in to change notification settings - Fork 986
Closed
Description
Operating System
IOS
Environment (if applicable)
NextJS
Firebase SDK Version
11.6.0
Firebase SDK Product(s)
AppCheck
Project Tooling
NextJS App
Detailed Problem Description
When running AppCheck on a WebKit browser e.g. in a Facebook message it throws a "Application error: a client-side exception has occurred" and looking at the logs the reason is - reCAPTCHA placeholder element must be an element or id
Steps and code to reproduce issue
export const AppCheckProvider = ({ children }) => {
const firebaseApp = useFirebase();
const [appCheck, setAppCheck] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (firebaseApp) {
try {
const siteKey = process.env.NEXT_PUBLIC_APP_CHECK_KEY;
self.FIREBASE_APPCHECK_DEBUG_TOKEN = process.env.NODE_ENV !== "production";
// Look in console logs for token and save to firebase appCheck console for Dev
const appCheckInstance = initializeAppCheck(firebaseApp, {
provider: new ReCaptchaEnterpriseProvider(siteKey),
isTokenAutoRefreshEnabled: true // Set to true to allow auto-refresh.
});
console.log("appCheckInstance: ", appCheckInstance)
setAppCheck(appCheckInstance);
} catch (error) {
console.error("App Check initialization error", error);
} finally {
setLoading(false);
}
}
}, [firebaseApp]);
// Show loading only if Firebase app is available but App Check is still initializing
if (firebaseApp && loading) {
return <Loading />;
}
return (
<AppCheckContext.Provider value={appCheck}>
{children}
</AppCheckContext.Provider>
);
};I am initiating AppCheck in a provider in the main layout.