I am currently running a node js server on Google App Engine, in the server, I am using firebase-admin package to interact with firebase. I am following the docs https://firebase.google.com/docs/admin/setup and initialise the app like this:
import admin from 'firebase-admin';
const NODE_ENV = process.env.NODE_ENV;
if (NODE_ENV === 'production') {
admin.initializeApp();
} else {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const firebaseAccountCredentials = require('../../credentials.json');
const serviceAccount = firebaseAccountCredentials as admin.ServiceAccount;
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});
}
export const db = admin.firestore();
It works all fine locally, as I am passing the credentials however when it is run inside App Engine, I see this error: details: 'The Cloud Firestore API is not available for Datastore Mode projects.'.
Do I have to set service accounts to connect to firebase? If so how? Couldn't find the documentation for that.
This is my app.yaml
runtime: nodejs
env: flex
Thanks