Open nidegen opened 1 month ago
Hey @nidegen, thanks for sharing code snippets. Looking through the Google Cloud Function logs while trying to replicate this, it seems like a Firebase app with the name of firebase-frameworks
was initialized. In your pages/invite/[id].tsx
file, could you try changing:
if (admin.apps.length == 0) {
admin.initializeApp();
}
const host = req.headers.host;
const projectId = admin.instanceId().app.options.projectId;
To
const ADMIN_APP_NAME = "firebase-frameworks";
const adminApp =
admin.apps.find((app) => app?.name === ADMIN_APP_NAME) ||
admin.initializeApp(
{
credential: admin.credential.applicationDefault(),
},
ADMIN_APP_NAME
);
const host = req.headers.host;
const projectId = admin.instanceId(adminApp).app.options.projectId;
After deploying, is a 500 error still being raised when visiting /invite/1234
?
I have a Next.js page hosted on firebase. It has one SSR page that loads firebase admin SDK as
and everything works fine.
As soon as I add
"firebase": "^10.8.0",
topackage.json
, the firebase-deployed site crashes during SSR withHowever, the logs show that
Init Firebase admin App
was logged before the crash.Any ideas what could cause it?
Here an MRE. Running it locally with Next.js works fine, but after deploying it to firebase,
/
works, but/invite/1234
crashes with a 500 error.package.json
pages/_app.tsx
pages/invite/[id].tsx