Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change region of firebase cloud functions of callable in v2

Hey so I am trying to upgrade to v2 of firebase cloud functions, but when trying to change the code I noticed that my functions do not have .region anymore like in v1.

Here the v1 version where I could call .region and change it

import * as functions from "firebase-functions";

exports.helloWorld = functions.region("europe-west1").https.onCall(() => {
  functions.logger.info("Hello logs!", { structuredData: true });

  return { text: "Hello from Firebase!" };
});

now I upgraded to v2, but I get:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Property 'region' does not exist on type 
'typeof import("/.../node_modules/firebase-functions/lib/v2/index")

Trying to achieve something like this for v2 of firebase cloud functions any ideas ?

import { https, logger } from "firebase-functions/v2";
import * as functions from "firebase-functions/v2";

// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//

const regionalFunctions = functions.region("europe-west1");

exports.helloWorld = regionalFunctions.https.onCall(() => {
  logger.info("Hello logs!", { structuredData: true });

  return { text: "Hello ${process.env.PLANET} and ${process.env.AUDIENCE}" };
});

>Solution :

You can specify the region in the function’s options as shown below:

import { onCall } from "firebase-functions/v2/https";

export const testFunction = onCall({ region: "..." }, (event) => {
  // ...
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading