私は角度のあるアプリで新しい Firestore を試している学生開発者で、セキュリティ ルールに行き詰まりました。
私が達成しようとしていること:
テンプレート バインディングを使用して、firestore ドキュメントを角度付きビューで表示します。ドキュメントは、認証されていないユーザーが閲覧できる必要があります。
問題:
認証されていないユーザーがページを表示しようとすると、権限エラーが発生します。
エラー エラー: 権限がないか不十分です。新しい FirestoreError (error.js:164) で
テンプレートファイル:
<p>{{ (item | async)?.name }}</p>
component.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();
}
ファイアストアのルール:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}