我是一名學生開發人員,嘗試使用我的角度應用程序中的新Firestore並卡住了安全規則。angular + firestore:如何允許公衆讀取文檔
我想要實現:
顯示使用模板結合的角度視圖一個公司的FireStore文件。該文檔應該可以查看未經認證的用戶。
問題:
如果非認證的用戶試圖查看的頁面權限錯誤發生:
ERROR Error: Missing or insufficient permissions. at new FirestoreError (error.js:164)
模板文件:
<p>{{ (item | async)?.name }}</p>
的組件。 ts文件:
interface Profile {
name: string;
}
...
private itemDoc: AngularFirestoreDocument<Profile>;
item: Observable<Profile>;
...
ngOnInit() {
this.itemDoc = this.afs.doc<Profile>('profiles/0mlC8uWaKeArzk0sfIfX');
this.item = this.itemDoc.valueChanges();
}
個
公司的FireStore規則:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
謝謝!我沒有閱讀正確的規則 –