J'utilise Nuxt.js + Firebase Firestore et j'essaie d'obtenir des données à partir d'une collection dont le nom est TestCollection mais le résultat est le suivant
Erreur dans l'obtention du document : FirebaseError : Permissions manquantes ou insuffisantes.
mon localhost affiche ceci.
Error getting document: FirebaseError: Missing or insufficient permissions.
at new n (prebuilt-306f43d8-45d6f0b9.js?a6a6:188)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:10426)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:10427)
at n.onMessage (prebuilt-306f43d8-45d6f0b9.js?a6a6:10449)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:10366)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:10397)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:15160)
at eval (prebuilt-306f43d8-45d6f0b9.js?a6a6:15218)
voici la méthode qui appelle la collection.
async testPost(){
try{
await this.$fire.firestore.collection('TestCollection').get()
.then((docs) => {
console.log('docs:', docs)
if (docs) {
docs.forEach((doc) => {
console.log(doc.data())
})
} else {
console.log('No such document!')
}
}).catch((error) => {
console.log('Error getting document:', error)
})
}catch (err){
console.log(err)
}
},
dans nuxt.config.js
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
['@nuxtjs/firebase', {
config: {
apiKey: process.env.FIREBASE_API_KEY,
authDomain: process.env.FIREBASE_AUTH_DOMAIN,
projectId: process.env.FIREBASE_PROJECT_ID,
storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID,
},
services: {
firestore: true,
storage: true,
database: true,
},
}],
],
dans database.rules.json
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "false"
}
},
"cases": {
".read": true
}
}
}
dans filetore.rules
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}