I have set up a cloud function in my Firebase console with the following inside the index.js
.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors');
const serviceAccount = require("./serviceAccountKey.json");
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "https://**********.firebaseio.com"
});
const authCheck = (req, res) => {
cors(req, res, () => {
const tokenId = req.get('Authorization').split('Bearer ')[1];
return admin.auth().verifyIdToken(tokenId)
.then((decoded) => res.status(200).send(decoded))
.catch((error) => res.status(401).send(error));
});
};
module.exports = {
authCheck: functions.https.onRequest(authCheck),
};
Whenever I try to access to the URL of this HTTPS endpoint, the cloud function always times out. I'm not able to debug what the issue is because the log in the console is in the form of blank lines.