How can I specify the region of a Google Cloud Function?

前端 未结 3 1287
梦谈多话
梦谈多话 2021-01-13 16:36

I\'m currently using Google Cloud Function to build up my restful API. However, I\'ve found that it\'s slow because the my Google-Cloud-Function server is on \"us-central\",

3条回答
  •  有刺的猬
    2021-01-13 17:34

    If you are using the Firebase SDK:

    Taken from the documentation - https://firebase.google.com/docs/functions/manage-functions#modify

    // before
    const functions = require('firebase-functions');
    
    exports.webhook = functions
        .https.onRequest((req, res) => {
                res.send("Hello");
        });
    
    // after
    const functions = require('firebase-functions');
    
    exports.webhookAsia = functions
        .region('asia-northeast1')
        .https.onRequest((req, res) => {
                res.send("Hello");
        });
    

提交回复
热议问题