简体   繁体   中英

Cloud Functions for Firebase - Getting Network error even though I'm making outbound http request for firebase-admin functionality

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 not doing any outbound networking on your 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 a 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.

to be able to make external requests in firebase cloud functions, you have to choose a plan first. Flame or Blaze plans in console.firebase.google.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM