Firebase的云端函数 - 即使我正在发送Firebase管理功能的出站http请求,也会收到网络错误 [英] Cloud Functions for Firebase - Getting Network error even though I'm making outbound http request for firebase-admin functionality

查看:595
本文介绍了Firebase的云端函数 - 即使我正在发送Firebase管理功能的出站http请求,也会收到网络错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个函数文件,我现在所要做的就是访问Firebase的auth()函数,根据电子邮件检查用户是否存在,然后获取他们的uid。



我有一个Angular 2应用程序,我运行一个http请求来调用该函数,但任何时候我试图运行它,我得到这个错误:

 结算帐户未配置。外部网络不可访问,配额受到严重限制。配置结算帐户以删除这些限制

以下是我的代码:

  const functions = require('firebase-functions'); 
const admin = require('firebase-admin');
admin.initializeApp(functions.config()。firebase);
$ b / **
*通过电子邮件获取用户的函数
* /
exports.getUserByEmail = functions.https.onRequest((req,res)=> ; {
console.log('req',req);
return admin.auth()。getUserByEmail(req.query.email);
});

这种类型的东西不允许在 Spark

预先感谢!

解决方案

在Spark计划上执行时,会出现所有函数的警告消息。这只是一个警告 - 你可以忽略它,如果你在做自己的任何出站网络。



我们正在考虑更改或删除该消息它不那么令人困惑。

管理员SDK应该可以正常工作。但是,你的函数没有正确地返回一个响应,所以它不会显示任何内容。 HTTP触发器(请阅读这些文档)必须向客户端发送响应以终止一般。他们不会像其他类型的函数一样返回promise。


I have a functions file where all I'm currently trying to do is access the Firebase auth() functionality to check if a user exists, based on email, and then get their uid.

I have an Angular 2 app where I run an http request to call that function, but any time I try to run it, I get this error:

Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions

Here is my code:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

/**
 *  Function to get a user by email
 */
exports.getUserByEmail = functions.https.onRequest((req, res) => {
  console.log('req', req);
  return admin.auth().getUserByEmail(req.query.email);
});

Is this type of thing not allows on the Spark plan? I'm still in development of my app and this is the only thing I need working right now and I'd rather not have to start paying right away just to use this tiny feature. Is there anything I can do?

Thanks in advance!

解决方案

That warning message appears for all functions when executing on the Spark plan. It's just a warning - you can ignore it if you're doing doing any outbound networking in your own own.

We're looking into getting that message changed or removed so that it's less confusing.

The admin SDK should work fine. However, your function doesn't return an response properly, so it won't appear to do anything. HTTP triggers (please read those docs) must send a response to the client to terminate normally. They don't return promises like the other types of functions.

这篇关于Firebase的云端函数 - 即使我正在发送Firebase管理功能的出站http请求,也会收到网络错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆