Search code examples
node.jsgoogle-cloud-functionsfirebase-tools

I want to set region for Firebase Functions in nodeJS project


While creating a project, I selected the region asia-south1, but I am surprised when I deploy the functions URL started from us-central1

I want to know, What is the current region for my firebase function, I want to set it as asia-south1.

Any help will be appreciable.

Thanks.


Solution

  • You can find how to change a GCF region in the Firebase documentation:

    By default, functions run in the us-central1 region. Note that this may be different from the region of an event source, such as a Cloud Storage bucket. If you need to change the region where a function runs, follow the recommendations in this section for each function trigger type.

    To set the region where a function runs, set the region parameter in the function definition as shown:

    exports.myStorageFunction = functions
        .region('asia-south1')
        .storage
        .object()
        .onFinalize((object) => {
          // ...
        });
    

    You can specify multiple regions by passing multiple comma-separated region strings in functions.region().