Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Build error: Service account object must contain a string "project_id" property #23

Closed
RachelHow opened this issue Sep 24, 2020 · 4 comments

Comments

@RachelHow
Copy link

RachelHow commented Sep 24, 2020

Hi @leerob! I love your React 2025 course 👍

Just a tiny issue that I ran into and failed to find solutions online. I tried deploying my code to Vercel and during build time, this is the error:

type: 'FirebaseAppError',
errorInfo: {
  code: 'app/invalid-credential',
  message: 'Service account object must contain a string "project_id" property.'
},

In my firebase.js and firebase-admin.js, I have set the projectId and project_id respectively.
I have also included the environment variables in .env, .env.local and Vercel environment variable settings.

@leerob
Copy link
Owner

leerob commented Sep 24, 2020

Are those values set to environment variables? If so, you'll need to ensure you add the environment variables inside your Vercel project as well – for both the preview and production environments.

@RachelHow
Copy link
Author

Hi @leerob , yes they are set to env settings in Vercel project :) On production, preview and development environments.

@leerob
Copy link
Owner

leerob commented Sep 24, 2020

@RachelHow
Copy link
Author

Hey @leerob, I replaced all the API keys on Vercel again to make sure there's no mistake.

After that, I ran into an error: Error: Failed to parse private key: Error: Invalid PEM formatted message.
To fix it, I added this to firebase-admin.js:
private_key: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n'),

And it's solved! Thank you so much. 👍

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

No branches or pull requests

2 participants