Uncaught (in promise) FirebaseError: Missing or insufficient permissions when trying to update collection

i am createing a microblogging app using firebase firestore and im getting this error

`const handleNewPostSubmit = async (e) => {
e.preventDefault();

const createdAt = new Date().toISOString();

await firestore.collection('posts').add({
  text: newPostText,
  createdAt,
});`

this is the code i used but i get the error Uncaught (in promise) FirebaseError: Missing or insufficient permissions.

and im also getting the warning
[2023-02-24T03:48:58.451Z] @firebase/firestore: Firestore (9.17.1): Uncaught Error in snapshot listener: FirebaseError: [code=permission-denied]: Missing or insufficient permissions

i wanted this to create a collections posts and add the new post to it