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

next-firebase-auth must be initialized before rendering. #692

Closed
amirhega opened this issue Nov 27, 2023 · 2 comments
Closed

next-firebase-auth must be initialized before rendering. #692

amirhega opened this issue Nov 27, 2023 · 2 comments

Comments

@amirhega
Copy link

amirhega commented Nov 27, 2023

Describe the bug
Occasionally in prod, I get this error in my next js API route:
error Error: next-firebase-auth must be initialized before rendering. at l (/var/task/node_modules/next-firebase-auth/build/index.node.js:2:9348) at /var/task/node_modules/next-firebase-auth/build/index.node.js:2:17669 at /var/task/node_modules/next-firebase-auth/build/index.node.js:2:16230 at Object.next (/var/task/node_modules/next-firebase-auth/build/index.node.js:2:16335) at /var/task/node_modules/next-firebase-auth/build/index.node.js:2:15250 at new Promise (<anonymous>) at u (/var/task/node_modules/next-firebase-auth/build/index.node.js:2:14995) at g (/var/task/node_modules/next-firebase-auth/build/index.node.js:2:17525) at applyPromoCode (/var/task/.next/server/pages/api/stripe/coupons/apply-promo.js:1:1186) at /var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16498
Iam calling init auth in my _app so I don't know why it wouldn't work. It happens in this part of my logic const token = req.headers.authorization?.split(" ")[1] || "" try { if (token) { const decodedToken = await verifyIdToken(token) const { id } = decodedToken if (!id || id !== user?.id) { throw new Error("Invalid token") } }

Versions

next-firebase-auth version: 1.0.0-beta1
Firebase JS SDK (firebase): 10.0.0
Firebase admin SDK (firebase-admin): 11.9.0
Next.js: pages, 13.5.3

To Reproduce
Cannot figure out how to reproduce it. I am calling init auth in _app.

Expected behavior
A clear and concise description of what you expected to happen.

@lazycipher
Copy link

@amirhega, were you able to figure it out?

@kmjennison
Copy link
Contributor

I suspect this is a duplicate of #614. Please try initializing the Firebase JS SDK yourself prior to initializing next-firebase-auth. Let me know if the problem persists after that.

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

No branches or pull requests

3 participants