How to protect firebase Cloud Function HTTP endpoint to allow only Firebase authenticated users?

With the new firebase cloud function I’ve decided to move some of my HTTP endpoint to firebase. Everything works great… But i have the following issue. I have two endpoints build by HTTP Triggers (Cloud Functions) An API endpoint to create users and returns the custom Token generated by Firebase Admin SDK. An API endpoint … Read more

How do I structure Cloud Functions for Firebase to deploy multiple functions from multiple files?

I would like to create multiple Cloud Functions for Firebase and deploy them all at the same time from one project. I would also like to separate each function into a separate file. Currently I can create multiple functions if I put them both in index.js such as: exports.foo = functions.database.ref(‘/foo’).onWrite(event => { … }); … Read more

How can I solve the error ‘TS2532: Object is possibly ‘undefined’?

I’m trying to rebuild a web app example that uses Firebase Cloud Functions and Firestore. When deploying a function I get the following error: src/index.ts:45:18 – error TS2532: Object is possibly ‘undefined’. 45 const data = change.after.data(); This is the function: export const archiveChat = functions.firestore .document(“chats/{chatId}”) .onUpdate(change => { const data = change.after.data(); const … Read more

Enabling CORS in Cloud Functions for Firebase

I’m currently learning how to use new Cloud Functions for Firebase and the problem I’m having is that I can’t access the function I wrote through an AJAX request. I get the “No ‘Access-Control-Allow-Origin’” error. Here’s an example of the function I wrote: exports.test = functions.https.onRequest((request, response) => { response.status(500).send({test: ‘Testing functions’}); }) The function … Read more