Still get FirebaseError: Request failed with error: Missing or insufficient permissions even all the configs are correct

I’m trying to read from database using below code and Firebase rule;

const firebaseConfig = {
    apiKey: "mykey",
    authDomain: "mydomain",
    projectId: "myprojectid",
    storageBucket: "mystoragebucket",
    messagingSenderId: "myid",
    appId: "myapid",
    measurementId: "mymeasurementid",
  };

  // Initialize Firebase
  const app = initializeApp(firebaseConfig);

  const db: any = getFirestore(app);

  // Get a list of cities from your database
  async function getCities(db: any) {
    const citiesCol = collection(db, "/posts");
    const citySnapshot = await getDocs(citiesCol);
    const cityList = citySnapshot.docs.map((doc) => doc.data());
    return cityList;
  }

I get this from Firebase docs, but I still get

FirebaseError: Request failed with error: Missing or insufficient permissions.

I DO NOT want to allow the database for everyone, I want it only myself have permissions. I have this rule on Firebase

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null
    }
  }
}

What should I do? How can I get rid of this error? There is not even a good answer on the web for “no one can access to the database but myself”.