Error 403 Forbidden. No permission to access the URL

Viewed 4149

I am trying to migrate to firebase. But before that I gave it a small try by performing the following one. I have successfully added and deployed cloud function but am getting a error

Error: Forbidden

Your client does not have permission to get URL /app/lol from this server.

This is occurring on execution of following code:

const functions = require('firebase-functions');
const express = require('express');
const app = express()
// tried adding this as middleware
// const cors = require('core'({origin: true}))
var admin = require('firebase-admin');

// app.use(cors)
var serviceAccount = require("./ServiceAccount.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://<my-app>.firebaseio.com/"
});


app.get('/lol', (req, res) => {
    res.send(`${Date.now()}`);
})

exports.site = functions.https.onRequest(app);

my firebase.json is as following:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "rewrites" :[{
      "source" : "**",
      "function" : "app"
      }],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}

when i go to the route, it takes me to the google auth and after signing through correct account. I get the error.

Whats the issue here!

1 Answers
Related