Adding Firebase service_key.json without committing the file to Git
Firebase service_key json file contains sensitive information so mentioned in his video that you should never commit it to git.
Another way to add the service_key is with environment variables.
Copy all the contents in the file and paste it in https://www.textfixer.com/tools/remove-line-breaks.php for removing line breaks and copy the content without line breaks in environment variable.
FIREBASE_SERVICE_ACCOUNT_KEY='JSON file content without line breaks'
And in firebaseAdmin.ts file, change this
const serviceKey = require("./service_key.json");
into
const serviceKey = JSON.parse(
process.env.FIREBASE_SERVICE_ACCOUNT_KEY as string
);
And when adding the environment variable in vercel don't put single quote.
6
7 comments
Hein Htoo
5
Adding Firebase service_key.json without committing the file to Git
University of Code
skool.com/universityofcode
You'll get Exclusive Lessons & Content, Badass Community Support & More here to elevate as a Dev!
Leaderboard (30-day)
Powered by