Hi, I am new to the Firebase Ecosystem so please bear with me. I am trying to run an ExpressJS server within a cloud function, and I am trying to connect SQL Connect service to the server within the function. However I am running into the below issue:
[REQUIRED] Environment info
firebase-tools: 15.17.0
Platform: Windows
Node Version: 22.22.0
Typescript: ^5.7.3
Firebase admin: 13.6.0
Firebase Functions: ^7.0.0
[REQUIRED] Test case
- Run an ExpressJS with TS server inside a firebase function. I followed the guide here: https://firebase.google.com/docs/functions/http-events
import functions from "firebase-functions/v2/https";
const express = require('express');
const app = express();
// Expose Express API as a single Cloud Function:
export const be= functions.onRequest(app);
-
Initialise the Firebase SQL Connect SDK using the Manual Installation instructions given here
https://firebase.google.com/docs/sql-connect/quickstart?userflow=manual#code-examples
-
Modify the code such that it calls InitializeApp(), and then the GetDataConnect
import functions from "firebase-functions/v2/https";
const express = require('express');
const app = express();
try {
firebaseApp = getApp();
} catch (error) {
firebaseApp = initializeApp();
}
app.use(cors({origin: true}));
if (!firebaseApp) {
throw new Error("Failed to initialize Firebase app");
}
const dataConnect = getDataConnect(connectorConfig);
// [Optionally] Configure the SDK to use Data Connect local emulator.
connectDataConnectEmulator(dataConnect, 'localhost', **9399)**
// Expose Express API as a single Cloud Function:
export const be= functions.onRequest(app);
[REQUIRED] Steps to reproduce
- With the previous code setup, and Typescript installed on the server, run
tsc && firebase emulators:start
[REQUIRED] Expected behavior
App to start as per normal with Firebase function emulator able to connect to SQL Connect emulator
[REQUIRED] Actual behavior
Receiving the below logs
**FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call initializeApp() first (app/no-app).
at Object.getApp (D:\repos\Presence\presence_be\node_modules\@firebase\app\dist\index.cjs.js:729:29)
at getDataConnect (D:\repos\Presence\presence_be\node_modules\@firebase\data-connect\dist\index.node.cjs.js:3062:21)
at Object.<anonymous> (D:\repos\Presence\presence_be\functions\lib\index.js:60:55)
at Module._compile (node:internal/modules/cjs/loader:1706:14)
at Object..js (node:internal/modules/cjs/loader:1839:10)
at Module.load (node:internal/modules/cjs/loader:1441:32)
at Function._load (node:internal/modules/cjs/loader:1263:12)
at TracingChannel.traceSync (node:diagnostics_channel:328:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
at Module.require (node:internal/modules/cjs/loader:1463:12) {
code: 'app/no-app',
customData: { appName: '[DEFAULT]' }
}
Hi, I am new to the Firebase Ecosystem so please bear with me. I am trying to run an ExpressJS server within a cloud function, and I am trying to connect SQL Connect service to the server within the function. However I am running into the below issue:
[REQUIRED] Environment info
firebase-tools: 15.17.0
Platform: Windows
Node Version: 22.22.0
Typescript: ^5.7.3
Firebase admin: 13.6.0
Firebase Functions: ^7.0.0
[REQUIRED] Test case
Initialise the Firebase SQL Connect SDK using the Manual Installation instructions given here
https://firebase.google.com/docs/sql-connect/quickstart?userflow=manual#code-examples
Modify the code such that it calls InitializeApp(), and then the GetDataConnect
[REQUIRED] Steps to reproduce
tsc && firebase emulators:start[REQUIRED] Expected behavior
App to start as per normal with Firebase function emulator able to connect to SQL Connect emulator
[REQUIRED] Actual behavior
Receiving the below logs