I am trying to use my NodeJS server to perform some queries along with serving my Angular app, but some weird things are going on, when I add any firebase command...
I have no idea why this version of app works without any errors:
const express = require('express');
const admin = require('firebase-admin')
const path = require('path')
const app = express();
const distDir = __dirname + "/dist/my-firebase-admin-app";
const serviceAccount = require('./admin-sdk-secret.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "...myURL..."
});
app.use(express.static(distDir));
app.use('*', (req, res) => {
res.sendFile(path.resolve(distDir +'index.html'));
});
app.listen(process.env.PORT || 8080);
but this crashes after a few seconds:
const express = require('express');
const admin = require('firebase-admin')
const path = require('path')
const app = express();
const distDir = __dirname + "/dist/my-firebase-admin-app";
const serviceAccount = require('./admin-sdk-secret.json');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "...myURL..."
});
admin.database().ref('/admins');
app.use(express.static(distDir));
app.use('*', (req, res) => {
res.sendFile(path.resolve(distDir +'index.html'));
});
app.listen(process.env.PORT || 8080);
The only thing I add is just firebase ref. What is wrong?