I know the issue of Missing or insufficient permissions has been asked before, but after weeks of Googling and searching I could not find an answer.
I've written a Firebase Cloud Function that triggers every time data is added to my Firestore database, it was all working fine, until one day it wasn't anymore, the function can read data from the database but it cannot write to it, it comes with the "Missing or insufficient permissions" error.
This is my code:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
const runtimeOpts = {
timeoutSeconds: 30,
memory: '2GB'
}
exports.titlePage = functions.region("europe-west2").runWith(runtimeOpts).firestore.document('savedCards/{userId}')
.onCreate(async (request, response) => {
console.log(request.data().url)
const title = "Hey!"
return request.ref.set({
title: title,
}, {merge: true});
});
And my security rules, which should allow anyone to write to the database:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Thank you!!