Change region of firebase cloud functions of callable in v2

Advertisements

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:

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) => {
  // ...
})

Leave a ReplyCancel reply