Skip to content

Commit 91fde67

Browse files
fix: update Firestore collection configuration and enhance logging for better environment variable management
1 parent b12600c commit 91fde67

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

src/server.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,30 @@ async function onCreateSendEmail(snap: FirebaseFirestore.DocumentSnapshot, _cont
304304
}
305305
}
306306

307+
/**
308+
* Must be the same collection the Angular client writes to (`getRuntimeEnv('FIRESTORE_COLLECTION_MESSAGES')`
309+
* from `src/assets/env.js`, generated by `generate-browser-env.mjs` from `.env`).
310+
* If unset in the Functions runtime, Cloud Functions previously defaulted to `testing`, which caused 0 invocations
311+
* when the app wrote elsewhere. Set `FIRESTORE_COLLECTION_MESSAGES` in Firebase (or `.env` for emulators) if you use a different name.
312+
*/
307313
const firestoreMessagesCollection =
308-
String(process.env['FIRESTORE_COLLECTION_MESSAGES'] ?? '').trim() || 'testing';
314+
String(process.env['FIRESTORE_COLLECTION_MESSAGES'] ?? '').trim() ||
315+
'messages_new_after_migration';
316+
317+
functions.logger.info('contactFormFunction: configured Firestore trigger', {
318+
documentPath: `${firestoreMessagesCollection}/{messageId}`,
319+
envOverride: !!String(process.env['FIRESTORE_COLLECTION_MESSAGES'] ?? '').trim(),
320+
});
309321

310322
export const angularUniversalFunction = functions
311323
.region('europe-west3')
312324
.https.onRequest(app);
313325

314-
/** Any document ID — client uses `.add()` (auto IDs), not email as document ID. */
326+
/**
327+
* Region must match your **Firestore database** location (not necessarily the same as the HTTPS SSR function).
328+
* Default US Firestore (nam5) → `us-central1` triggers. EU DB (eur3) → use an EU region from Firebase’s table.
329+
* Keeping SSR in `europe-west3` and this trigger in `us-central1` is valid when the DB is US and you want EU edge for HTTP only.
330+
*/
315331
export const contactFormFunction = functions
316332
.region('us-central1')
317333
.firestore

0 commit comments

Comments
 (0)