Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initializing App Check local development not working #281

Open
nolafs opened this issue Nov 21, 2024 · 1 comment
Open

Initializing App Check local development not working #281

nolafs opened this issue Nov 21, 2024 · 1 comment

Comments

@nolafs
Copy link

nolafs commented Nov 21, 2024

Hi,

Seems there is an error initializing App Check when using login server action. Not possible to add the global variable to the window as there is no window on the server

⨯ src/app-check/index.ts (14:19) @ getOrInitializeAppCheck
⨯ ReferenceError: window is not defined
   at getOrInitializeAppCheck (./src/app-check/index.ts:14:19)
   at getFirebaseApp (./src/auth/firebase.ts:16:27)
   at getFirebaseAuth (./src/auth/firebase.ts:23:24)
   at loginAction (./src/actions/login.ts:11:69)
digest: "776069970"
 12 |   // Firebase uses a global variable to check if app check is enabled in a dev environment
 13 |   if (process.env.NODE_ENV !== 'production') {
> 14 |     Object.assign(window, {
    |                   ^
 15 |       FIREBASE_APPCHECK_DEBUG_TOKEN: process.env.NEXT_PUBLIC_APP_CHECK_DEBUG_TOKEN,
 16 |     });
 17 |   }
@awinogrodzki
Copy link
Owner

Hey @nolafs!

window is not available in server actions.

You can try to move signInWithEmailAndPassword and getFirebaseAuth call to the client, and pass idToken to the loginAction directly from client instead. Let me know if that works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants