Questions tagged [google-cloud-functions]

Google Cloud Functions revolutionizes the way developers work by providing a nimble, event-driven computing solution. It empowers you to effortlessly build compact, specialized functions in Node.js, Python, or Go which seamlessly react to cloud events—eliminating the burden of server and runtime environment management.

Firebase response comes back as a successful 200 code, however the array returned

I've been working on a project involving Firebase and Firebase functions. Right now, I'm struggling to retrieve documents from a collection called 'items'. When I try to make a GET request, all I get is a 200 status code with an empty r ...

What is the process for invoking an External Javascript Firestore function within a Typescript file?

Trying to figure out how to integrate a Firestore trigger written in an external JavaScript file (notifyNewMessage.js) into my TypeScript file (index.ts) using Node.js for Cloud functions. Both files are located in the same directory: https://i.stack.imgu ...

Error: The argument passed to the function must be an Array type. Undefined value was received instead of an array

Looking for some assistance with this coding issue, hoping someone with expertise can lend a hand! (Not my forte) I've written this Typescript code snippet for a basic CloudFunction export const add2list = functions.https.onRequest((req:any , res:any ...

What is the method for retrieving req.originalUrl within a Firebase Cloud Function's onRequest event handler?

Currently, I am utilizing a Firebase serverless function to store my leads. I have the belief that Firebase leverages the request object from express.js. Consequently, I've included my code below: export const addLead = functions .https.onRequest(async ...

Tips for speeding up the process of sending emails with nodemailer and firebase

We've successfully implemented code that triggers emails to a user and their contacts whenever a new node is added to a specific path in Firebase's realtime database. Currently, the average time taken to send these emails is approximately 4 minu ...

Is there a way to prevent the admin from invoking Firebase functions?

I currently have two triggers set up in my Firebase functions: user onUpdate owner onUpdate When the owner onUpdate trigger is activated, it performs an operation and updates the user document accordingly. The user onUpdate trigger is invoked by the pr ...

What methods are available to rapidly test Firebase functions?

While working with Typescript on firebase functions, I have encountered challenges in testing and experimenting with the code. Despite using the Lint plugin to identify errors without running the code, I am struggling to run the code and view the output. ...

Struggling with slow response times when interacting with Firestore in Firebase Cloud Functions?

I am currently experiencing performance issues with a simple Cloud Function in Firebase. This function is responsible for taking JSON data through an HTTP POST request and storing it in a Firestore collection. Despite being assigned 512MB of memory, the pe ...

There seems to be an issue with Google Cloud Function - res.setHeader function is not recognized

I attempted to run the initial example from the Cloud Functions Documentation. I went ahead and created my function, then simply copied and pasted the example code provided in the docs. Correction: Instead of using the original example, I took the code sn ...

Travis encounters issues deploying Firebase with a script due to an unsupported environment and the fsevents Darwin error

Currently in the process of upgrading my Travis environment to node 20, where I am running a script that deploys Firebase functions. Below is my .travis.yml file: ... install: bash $HOME/build/ChangEdApps/changed-javascript/backend/shellScripts/travis-scr ...

Efficiently integrating Firebase Functions with external sub path imports beyond the project's

I encountered an issue in my firebase functions project with typescript. The problem arises when I use types from outside the project with sub path imports, causing the build files to become distorted. Instead of having main:lib/index.js, I have main:lib/ ...

Error: Unable to use import statement outside of a module when deploying Firebase with TypeScript

Every time I try to run firebase deploy, an error pops up while parsing my function triggers. It specifically points to this line of code: import * as functions from 'firebase-functions'; at the beginning of my file. This is a new problem for me ...

Improving Firebase function performance by utilizing Express.js for reducing cold start times

Exploring ways to enhance cold start times for my Firebase functions led me to discover an article that focused on maximizing performance and readability using TypeScript with the base usage of the http onRequest function. However, I was eager to implement ...

Using express and consign for routing in Firebase Cloud Functions

I am looking to incorporate routing within my Express application, which will be exposed through a cloud function. Here is the content of my functions/index.js file : const functions = require('firebase-functions'); const express = require('express'); co ...

Troubleshooting: Issue with Deploying Function and Hosting Website on Firebase

When deploying database, storage, Firestore, functions, and hosting, you may encounter an error like the following: Running command: npm --prefix $RESOURCE_DIR run lint npm ERR! path D:\public\$RESOURCE_DIR\package.json npm ERR! code ENOENT ...

Storing data into Firebase database using a cloud function API

Below is a Firebase cloud function I have created that can be accessed through a REST API. My aim is to save the user-submitted values from the front end via the 'Web service URL': 1.) The data should be stored in the Firebase-realtime database. 2.) I c ...

Can Cloud Functions be used to establish a connection between Cloud Firestore and Realtime Database?

My current project involves designing my firebase database with a unique approach. I am looking to establish a connection between certain document fields in firestore and real-time database fields. This way, any changes made in the real-time database will ...

Error encountered during deployment of Cloud Functions due to missing dependencies in monorepository

I am facing an issue with my monorepo setup where my cloud functions are importing from another package within the workspace. The imported package is listed in the package.json under devDependencies as shown below: // stuff "dependencies": { &q ...

What is the most effective way to securely store a Token for Firebase cloud functions?

Currently, I have a Firebase cloud function that utilizes express middleware to generate an authToken and passes it through the routes. This token has a 24-hour lifespan, so to avoid overloading the service with excessive requests, I am looking to cache th ...

Need a key file from a specific path within a Google Cloud Function

I'm working with Google Cloud Functions that require a JSON key file. Here is an example: const SERVICE_ACCOUNT_EMAIL = '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="41382e34331e322433372822241e2022222e342f351e242 ...

Is it possible to create Firebase real-time database triggers in files other than index.js?

Is it possible to split a large index.js file into multiple files in order to better organize the code? Specifically, can Firebase triggers be written in separate JavaScript files? If so, could you please provide guidance on how to do this properly? child. ...

Issue encountered during deployment where Firebase functions are causing an exception to be

After creating Firebase functions to send notifications on data changes in Firestore, I encountered a problem when trying to transfer the code from my old computer to a new one. The commands are now throwing errors and I have been attempting to fix them fo ...

Issue with Firebase functions unexpected CORS error (unhandled promise rejection/CORS)

I'm experiencing a strange issue with Firebase functions that seems to be specific to mobile devices and only occurs immediately after a user logs in for the first time (refreshing the page resolves the issue). Here is the code snippet: const functions = ...

Organizing Firebase functions: Managing multiple functions and dependencies

Objective I aim to gain a deeper understanding of how the firebase CLI manages the deployment process for multiple firebase functions, each stored in different files, and how it handles dependencies that are specific to certain functions. Situation If I ...

Firebase scheduled function continues to encounter a persistent issue with an "UNAUTHENTICATED" error being consistently thrown

I have created a firebase-function that is scheduled to retrieve data from an external API source and save it in Firestore. const functions = require("firebase-functions"); const admin = require("firebase-admin"); const { default: Axios ...

Is it feasible to utilize cloud functions for the purpose of transferring videos to the Firebase server?

I am exploring the option of writing a cloud function to download a video file. Below is an example of how I plan to save the file in mp4 format: const http = require('http'); const fs = require('fs'); const file = fs.createWriteStream ...

The file functions/lib/functions/src/index.ts is missing, preventing the deployment of Cloud Functions

Whenever I attempt to deploy my Firebase cloud functions, I encounter the following error. Expected outcome: Successful deployment of functions. Error: Error: An issue occurred while reading functions/package.json: functions/lib/index.js is missing and ...

What steps can I take to deploy to Firebase functions without facing any npm dependency conflicts?

I've been working on setting up an Angular Universal project and encountered an issue when trying to deploy it. After successfully compiling it with npm run build:ssr, I faced errors while deploying using firebase deploy. === Deploying to 'terabu ...

Retrieve all documents from a Firebase User's collection

Recently, I created a Firebase cloud function where my goal is to access every user's internal collection named 'numbers' and examine each document within that collection for some comparisons. Do you have any insights on how I can achieve this? Despite b ...

Error: Unable to encode data into JSON format encountered while using Firebase serverless functions

I am currently working on deploying an API for my application. However, when using the following code snippet, I encountered an unhandled error stating "Error: Data cannot be encoded in JSON." const functions = require("firebase-functions"); const axios = ...

notification triggered by a real-time database

Written below is the code responsible for triggering a change in the real-time database: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); expor ...

Steps for retrieving multiple documents from Firestore within a cloud function

In my cloud function, I have set up a trigger that activates on document write. This function is designed to check multiple documents based on the trigger and execute if/else statements accordingly. I have developed a method that retrieves all documents u ...

Executing multiple instances of a Firebase cloud function

I am working with a Firebase (Google) cloud function that is structured like this // Initialize the Auth0 client var AuthenticationClient = require('auth0').AuthenticationClient; var auth0 = new AuthenticationClient({ domain: 'familybank.auth0.c ...

The cloud function that is callable is currently inactive and encountering errors upon invocation

I am experiencing issues with my Cloud Function which is supposed to call a request to the URL passed to it. This is my first time using TypeScript to make a request, so I added some print calls to troubleshoot the problem. However, the first log never app ...

Installation of Axios on Firebase Functions with Node.js 14 encountered errors

While working with Firebase Functions, I encountered an issue when attempting to install and use axios. Despite using npm install to add the package as shown below, the installation failed without any clear indication of what went wrong during runtime. Co ...

An issue occurred while attempting to retrieve Firebase data using an HTTP GET request

When trying to retrieve my data from firestore using an HTTP get request, I encountered an error. It might be helpful if my data in firestore was stored in JSON format. I'm not sure if this is feasible. <!DOCTYPE html> <html lang="en"> < ...

Exploring how to incorporate Express middleware into Firebase Functions for handling HTTPS requests

Encountering a challenge while using Express middleware with Firebase Functions. In this sample, a function is linked to the app() instance as shown below: app.get('*', (req, res) => { res.send(`Hello ${req.user.name}`); }); exports.authorizedHello ...

Is it possible to use an external table in Node.js to query cloud storage?

Is it possible to query cloud storage using the external table concept in Node.js? I found some code in Python that achieves this functionality, but I would prefer to implement the same logic in Node.js. Is there a way to do this? ...

Utilizing Google Cloud Functions with NPM

I'm currently attempting to utilize a Google Cloud function to convert a 3D model into an image. However, my function is failing to deploy. I have made attempts using both `ypm install` and `npm install` in the package file. Deployment error: Build failed ...

Monitor modifications to documents and their respective sub-collections in Firebase Cloud Functions

Is it possible to run a function when there is a change in either a document within the parent collection or a document within one of its subcollections? I have tried using the code provided in the Firebase documentation, but it only triggers when a docume ...

How can I return from cloud functions to Firebase Hosting?

So, here's my idea: to improve the search engine optimization (SEO) of my Single Page Application (SPA), I plan on detecting web crawlers on the server side using headers. If a crawler is detected, I want to render the page with Puppeteer and return it acc ...

Attempting to invoke a TypeScript firebase function

I'm currently working on incorporating Firebase functions in my index.ts file: import * as functions from "firebase-functions"; export const helloWorld = functions.https.onRequest((request, response) => { functions.logger.info("Greet ...

Deployment of Firebase Cloud Function encountered an error stating "Oops! Something unexpected happened."

Whenever I run firebase deploy, firebase deploy --only functions, or firebase deploy --only functions:functionName, I keep receiving the dreaded message: Error: An unexpected error has occurred. Please do not flag this as a duplicate question, as I have th ...

Encountering a Firebase deployment problem: Issue with build process: npm error! Call stack size surpasses the

I am encountering an issue while trying to deploy my Firebase Cloud Function using the following command: firebase deploy --only functions:helloWorld Although the command succeeds occasionally, most of the time it fails with the error mentioned above. Wha ...

Optimizing Firebase and Next.js for serverless deployment on Google Cloud Platform: A guide to effectively managing staging, production, and

Currently, I am utilizing React along with next.js and Google Cloud functions to host my application. Additionally, I am integrating firebase into the mix. One pressing issue I am facing pertains to efficiently configuring the staging and production enviro ...

Simple method for wrestling with objects in TypeScript HTTP POST responses

Can anyone help me understand how to extract information from an object received through an HTTP POST request? Below is the code I am using: this.http.post(url, user, httpOptions).subscribe(result => { console.log(result.status); }); The issue aris ...

Encountering the 'unable to set headers' issue when using Axios in Firebase Functions, but the function continues to run smoothly despite the error

Having an issue with my Firebase function that triggers on a Stripe webhook via express. The function itself runs smoothly, but I keep encountering an error when trying to send an email (using Axios): Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after ...

What could be causing the SignatureDoesNotMatch error when attempting to save thumbnail URLs using Firebase Storage Cloud Storage triggers?

Using the firebase resize extension to automatically create resized pictures, such as turning user1profile into user1profile_320x320. A trigger function is in place to update documents in firestore once the thumbnail is generated: const isThumbna ...

Error when trying to use Firebase CLI console: Module @google-cloud/tasks cannot be located

My index.js file has a dependency on Cloud Tasks: const {CloudTasksClient} = require("@google-cloud/tasks"). However, when attempting to deploy my cloud function using Tasks, I encountered the error: Detailed stack trace: Error: Cannot find module '@g ...

Is it necessary to verify the apiKey or does the authentication of the user suffice for an HTTPS callable function?

I'm interested in creating a cloud function that can be executed from both the client and the backend. After exploring the documentation, I learned that an HTTPS callable function will automatically include user authentication data, accessible through the ...

What is the best way to organize Google cloud functions across separate files?

As someone diving into the world of Google cloud functions and Node.js, I've found myself accumulating quite a lengthy Index.js file due to all the functions I've had to write. I'm curious if there's a way for me to allocate each function to its own sepa ...

Attempting to grasp the concept of Google Cloud Function for SendGrid's inbound parsing feature

I'm currently working on setting up a sendgrid designated URL at www.mydomain.com/mail/post. My goal is to create a Google Cloud Function that will respond to emails coming in from the inbound parse API. However, I'm facing issues with triggering the API w ...

Tips for creating TypeScript Google Cloud Functions using webpack

I'm currently facing a challenge while coding a Google Cloud Function using TypeScript. The concept involves having handler functions defined for various Cloud Functions in separate files within the source repository, along with some code that is shar ...

What could be causing the "502 Gateway" error specifically for POST requests in my NextJs app hosted on Firebase?

I've encountered an issue while trying to build an API with the NextJs framework and hosting it on Firebase (Hosting and Functions). The GET requests work fine, but when I try to send a POST request, I keep getting a "502 Bad Gateway" error. To replicate ...

It appears that Firebase custom claims are not functioning as expected

Encountering an issue with my project involving Node.js and Firebase. My goal is to implement an admin role by utilizing custom claims as outlined in the documentation. Within the cloud functions, I have three specific functions: exports.addAdminRole = fun ...

During the installation of firebase-tools, NPM repeatedly issued dependency warnings even though all dependencies had already been successfully installed

As I was upgrading my firebase-tools from version 8.6.0 to 8.7.0 using the command sudo npm i -g firebase-tools within my functions folder, I encountered the following warnings: npm WARN deprecated <a href="/cdn-cgi/l/email-protection" class="__cf_email ...

Allowing Cross-Origin Resource Sharing on an Express Server hosted using Firebase Cloud Functions

Hey there, I have a simple Express setup on Firebase, shown below: import { onRequest } from 'firebase-functions/v2/https'; import express from 'express'; import bodyParser from 'body-parser'; import router from './router.js'; import cors from 'cors'; co ...

Cloud Firestore trigger fails to activate Cloud function

I am facing an issue with triggering a Cloud Function using the Cloud Firestore trigger. The function is supposed to perform a full export of my sub collection 'reviews' every time a new document is added to it. Despite deploying the function successfully ...

Error in Firebase Functions: Promises must be properly managed

Currently, I am in the process of creating a Firebase function using TypeScript to deliver push notifications to multiple users. However, whenever I execute the command firebase deploy --only functions, TSLint flags an error stating "Promises must be han ...

Set up Admin SDK using appropriate credentials for the given environment

As someone new to Node.js, Firebase Cloud Functions, and TypeScript, my objective is to create a cloud function that acts as an HTTP endpoint for clients to authenticate with Firebase. The desired outcome is for the cloud function to provide a custom acces ...

Discover the method of invoking a Firebase Cloud Function which utilizes ExpressJS in conjunction with cloud_functions

I have integrated a Firebase Cloud Function with ExpressJS that I want to access from my mobile application. Instead of making a simple http request, I am considering using the cloud_firestore package in Dart/Flutter as it may handle authentication more s ...

Why does using `withCredentials: true` and including a `body` in the request cause a CORS error in Angular HttpClient?

My objective is to make a request to a Cloud Function, receive a response with a Set-Cookie header, and have the browser store the cookie. The issue arises when the response containing a Set-Cookie header is ignored without the presence of withCredentials ...

Notify users at scheduled time using Firebase and Cloud functions

I have developed a unique platform that allows fitness coaches to effectively communicate and share workout plans with their clients. However, I am looking to further enhance this platform by introducing a new feature: the ability for coaches to configure ...

Issues encountered when attempting to add a new user on Firebase

I am facing an issue with this function that is supposed to add new users to my firebase database, but for some reason, it's not working. exports.createUserWithEmailAndPassword = functions.https.onCall( async(data, context) => { const { admi ...

Experiencing issues updating firebase functions?

I'm encountering an error while trying to update my firebase functions: C:UsersMYNameAppDataRoaming pm ode_modulesfirebase-tools ode_modules@grpcgrpc-jsuildsrcindex.js:47 throw new Error(`@grpc/grpc-js only works on Node ${supportedN ...

Converting PHP code to Typescript

Currently, I am working on developing a function for firebase that will trigger a POST request to call a specific URL. While I have successfully implemented GET requests, tackling the POST method has proven to be more challenging. I have some sample code ...

Implementing conditional where clauses in Firestore queries with dynamic parameters

Consider this scenario: I have a dynamic filter list for my product list, and I want to send an HTTPS request to a cloud function based on the selected filters. However, when trying to set multiple conditional where clauses from that request... The multip ...

Execute a Cron Job every half an hour following the onCreate event in Firestore

Looking to set up a cron job or scheduler that runs every 30 minutes following an onCreate event in Firestore. The goal is to execute a cloud function that retrieves documents created within the last 30 minutes, validates them against a JSON schema, and ...

Timestamps Update in Cloud Functions Triggered by Warnings

My Firebase Cloud Functions setup looks like this: index.js const functions = require('firebase-functions'); const trackVote = require('./trackVote') const admin = require('firebase-admin'); admin.initializeApp(); exports.trackVote = trackVote.handler; ...

Guide on creating a Google function using Twilio to automatically send an SMS when there is a change in the Realtime database

I am currently working on my first Google Cloud Function and I have limited knowledge about it. My goal is to create a Google Cloud Function integrated with Twilio. Whenever the water level changes in my Realtime Database, I want to send an SMS to a specif ...

Sending a function from a local environment to a cloud function and storing it in a bucket

I have successfully implemented the following function on my node.js localhost: // index.js const scrape = require('website-scraper'); const PuppeteerPlugin = require('website-scraper-puppeteer'); const path = require('path'); ...

Is there a way to stop the Firebase web client from altering the error message generated by an https.onRequest function?

I am facing an issue where I cannot retrieve the original message I sent from an "https.onRequest" function in Firebase. The firebase client is rewriting the message based on the error code, making it difficult for me to recover the originally sent body or ...

Struggling with deploying to Firebase hosting

When I run firebase deploy, it runs for a few minutes before giving me a timeout error Error: ESOCKETTIMEDOUT I have successfully deployed multiple times before, without making any changes other than the frontend of my React project. My cloud functions i ...

There has been no answer provided. Could this be due to being utilized in an asynchronous function that was not returned as a promise?

I encountered the following error message: Error: No response has been set. Is this being used in an async call that was not returned as a promise to the intent handler? at DialogflowConversation.response (/user_code/node_modules/actions-on-google/dis ...

Invoke the express function on the client using the callable method

When I'm listening on a local port with my browser, the following method will return Hello world. //Node app.get('/', (req,res)=>{ res.send('Hello world') }); I've successfully exported the app as a ca ...