Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't specify a new region for cloud functions

I changed the location of my cloud functions from "us-central1" to "europe-west1" but I can't change the location of my functions on the client side which is a compulsory step for it to work according to the documentation.

(IDE tells me that no argument is expected on 'functions' when i do:

firebase.initializeApp(config).functions("europe-west1");

As an attempt to solve my problem I updated the three dependancies below with no result.

firebase-tools@latest firebase-functions@latest firebase-admin@latest

The problem is still here.

like image 260
Raphael St Avatar asked Apr 08 '19 22:04

Raphael St


1 Answers

You should visit the following documentation page.

  • https://firebase.google.com/docs/web/setup
  • https://firebase.google.com/docs/functions/manage-functions#modify-region
  • https://firebase.google.com/docs/functions/locations

client side

Use firebase.app.App.

https://firebase.google.com/docs/reference/js/firebase.app.App#functions

Not admin.app.App. The firebase-admin only use on the server side.

https://firebase.google.com/docs/reference/admin/node/admin.app.App

Set the specified regions for a client app.

var firebase = require("firebase/app");
require("firebase/functions");
var config = {
  // ...
};
firebase.initializeApp(config).;
var functions = firebase.app().functions('europe-west1');

server side(Cloud Functions)

Set the specified regions for each function.

const functions = require('firebase-functions');
 
exports.webhookEurope = functions
    .region('europe-west1')
    .https.onRequest((req, res) => {
        res.send("Hello");
    });

If you are changing the specified regions for a function that's handling production traffic, you can prevent event loss by performing these steps in order:

  1. Rename the function, and change its region or regions as desired.
  2. Deploy the renamed function, which results in temporarily running the same code in both sets of regions.
  3. Delete the previous function.
like image 99
zkohi Avatar answered Oct 12 '22 15:10

zkohi