0

Have deployed a few firebase functions (according to docs)

firebase init

Changed the code to something like

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();
exports.getUsers = functions
  .region('europe-west1')
  .https.onRequest((req, res) => {
    admin.firestore().collection('users').get().then(data => {
      const users = data.map(user => user.data());
      return res.json(users);
    }).catch(err => console.error(err));
  });

  exports.helloWorld = functions.https.onRequest((req, res) => {
    res.status(200).send('Hello, World!');
  });

Deployed it.

firebase deploy

And as an end result both of the functions return

Error: Forbidden Your client does not have permission to get URL /getUsers from this server.

Error: Forbidden Your client does not have permission to get URL /helloWorld from this server.

In the firebase admin console I see that functions exist, and they are there, and I am using same exact urls that the terminal gave me & are on the firebase admin console.

Any ideas?

PS. Located in Estonia.

Community
  • 1
  • 1
Alex
  • 814
  • 1
  • 10
  • 23
  • @Renaud Tarnec, well the proposed answer really didn't help, but what I did find out is that, Google Cloud functions are not free, and I must pay up in order to start using hence the error.. – Alex Mar 20 '20 at 11:22
  • Thanks for the feedback. I'll reopen your question. Note that normally, for your Cloud Functions (which do not include a call to a non-Google service), you should not need to pay, unless you go above the free Spark plan limits (see https://firebase.google.com/pricing) – Renaud Tarnec Mar 20 '20 at 11:28

1 Answers1

0

Alright,

To solve this issue I had to use my brain and check the dashboard for cloud functions. Cloud functions do not return a 500 error unlike most common APIs, instead inside of the dashboard I found out that:

TypeError: data.map is not a function
admin.firestore.collection.get.then.data ( /user_code/index.js:10 )

Meaning my 'application' was crashing, oddly enough it was giving me a 403 error. For good measure I also followed this:

Firebase cloud function "Your client does not have permission to get URL /200 from this server"

Alex
  • 814
  • 1
  • 10
  • 23