I tried to configure the GOOGLE_APPLICATION_CREDENTIALS environment variable on Netlify in order to use firebase-admin, but how do I get the actual JSON file there?
Obviously I cannot include it in git.
I tried to configure the GOOGLE_APPLICATION_CREDENTIALS environment variable on Netlify in order to use firebase-admin, but how do I get the actual JSON file there?
Obviously I cannot include it in git.
You can generate the admin credential certificate by piecing the credentials together using environment variables.
You will have to provide the project specific values to the Netlify runtime using Netlify's environment mechanism
and then instantiate the admin client like this
import admin, { app, AppOptions } from "firebase-admin";
const config: AppOptions = {
credential: admin.credential.cert({
projectId: process.env["FIREBASE_ADMIN_PROJECT_ID"],
clientEmail: process.env["FIREBASE_ADMIN_CLIENT_EMAIL"],
privateKey: process.env["FIREBASE_ADMIN_PRIVATE_KEY"].replace(/\\n/g, "\n"),
}),
// databaseURL: process.env.SVELTE_APP_FIREBASE_DATABASE_URL,
};
let firebaseAdminApp: app.App;
if (!admin.apps.length) {
firebaseAdminApp = admin.initializeApp(config);
} else {
firebaseAdminApp = admin.app();
}
export default firebaseAdminApp;