menu
Channels
# All channels
view-forward
# General
view-forward
# Announcements
view-forward
# Feedback
view-forward
# Guides
view-forward
# I Made This
view-forward
Team

Zeit deployment fails with FirebaseError

April 19, 2020 at 2:53pm

Zeit deployment fails with FirebaseError

April 19, 2020 at 2:53pm
Following the instructions given in README for zeit deployment, we get this error. What might be going on?
07:51:01.151
Build error occurred 07:51:01.155 Error [FirebaseError]: projectId must be a string in FirebaseApp.options 07:51:01.155 at new FirestoreError (/zeit/5f1f526a/node_modules/@firebase/firestore/dist/index.node.cjs.js:355:28) 07:51:01.155 at Function.Firestore.databaseIdFromApp

April 19, 2020 at 4:31pm
Hey , I believe this might be related to this, which will be fixed today. Mind trying the fix mentioned in this thread and letting me know if that does the trick?

incorrect .env vars for Firebase

thumbsup
2
message-simple
4
  • reply
  • like
Hey , for local development make sure environment vars are specific in .env and .env.build, and for deployment make sure you've added all the vars to your ZEIT account with now secrets add KEY VALUE. Could you let me know if that does the trick?
  • reply
  • like

April 20, 2020 at 2:45pm
Hi Gabe: It still has the same issue. These are the two things I tried -- (1) Changed all of the .env variables to have prefix REACTAPP e.g. REACT_APP_FIREBASE_PROJECT_ID (2) Added vars to now using now secrets add REACT_APP_FIREBASE_PROJECT_ID <value> , and, it still gives the same error.
  • reply
  • like
Okay, I’ll try to reproduce this today and see what’s going on here. Sorry about the trouble. Are you using the default React App option or Next.js?
Edited
like-fill
1
  • reply
  • like
I am using Next.js.
like-fill
1
  • reply
  • like
Okay, I believe I have a fix for you here. Remove the REACTAPP prefix from all keys in both .env and now.json.
Edited
like-fill
1
  • reply
  • like
keys in next.config.js should look like
REACT_APP_FIREBASE_API_KEY: process.env.FIREBASE_API_KEY,
REACT_APP_FIREBASE_AUTH_DOMAIN: process.env.FIREBASE_AUTH_DOMAIN,
etc...
Edited
  • reply
  • like
So next.config.js is the file responsible for prefixing vars to use client-side with REACTAPP
  • reply
  • like
.env provides local env values, now.json provides production env values
Edited
  • reply
  • like
And your secrets in now should not have the prefix either
  • reply
  • like
Let me know if that does the trick
  • reply
  • like
That did the trick you are awesome!!! :)
  • reply
  • like
Wooo glad to hear it! Thanks for your patience :)
  • reply
  • like