【问题标题】:firebase_functions/internal Response is not valid JSON object cloud functions when region is specified why?指定区域时,firebase 函数/内部响应不是有效的 JSON 对象云函数为什么?
【发布时间】:2021-03-04 02:08:38
【问题描述】:

当触发事件时,我尝试为我的 https on call 函数指定asia-south1,我在调试控制台中收到错误[firebase_functions/internal] Response is not valid JSON object cloud functions。在 firebase 云函数日志中。函数根本没有被触发。

代码 sn-p

//index.js

exports.disableUserAccount = functions.region("asia-south1").https.onCall(async (data, context) => {
  try {
    const uid = context.auth.uid;
    if (uid.length !== 0) {
      console.log("User uid : " + uid);
      await admin.auth().updateUser(context.auth.uid, {
        disabled: true,
      });
      console.log("User account disabled successfully");
    }
  } catch (error) {
    console.log("Error :" + error.toString());
  }
});

Flutter sn-p

import 'package:cloud_functions/cloud_functions.dart';

Future<void> callUserDisableFunction() async{
    try{
    FirebaseFunctions disableFunction = FirebaseFunctions.instance;
    var callFunction = disableFunction.httpsCallable("disableUserAccount");
    await callFunction();
    print("disableUserAccount function is triggered");
    } catch (error){
      print("Error in https callable : ${error.toString()}");
    }
  }

注意: 使用默认区域 us-central1 进行部署可以正常工作。 为什么我不能在 https on call 中指定区域?它是如何与us-central1 合作的?

【问题讨论】:

    标签: node.js firebase google-cloud-functions


    【解决方案1】:

    正如the docs所提到的

    Firebase 托管仅在 us-central1 中支持 Cloud Functions。

    您可能知道 Firebase Functions 是背后的 GCP 功能,但 Firebase Hosting 仅支持 us-central1,您可以查看像 cloud run 这样的替代方案,因为 Firebase 托管支持。

    【讨论】:

      猜你喜欢
      • 2021-01-21
      • 2020-07-26
      • 2021-06-24
      • 2022-07-07
      • 2019-08-25
      • 2021-03-03
      • 2020-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多