I have a simple program to show realtime postview counts. But in firebase, it says Your security rules are defined as public, so anyone can steal, modify, or delete data in your database. Even every night it sends me an email in gmail about this warning. What is the solution?
If I change rules, it do not show or count postviews, and do not work. Actually I have set it up in my blogger blogspot website to count post views.
HTML Code:
<span class='post-view' data-id='11220'>
<span class='view-load' id='postviews'><span>
views
</span>
Here is my Javascript code to show postviews:
document.addEventListener("DOMContentLoaded", function() {
var pvin = "tbt-postview-counter";
if (!pvin) return console.error("Firebase URL not found!");
let s = document.createElement("script");
s.src = "https://cdn.firebase.com/js/client/2.3.2/firebase.js";
s.onload = () => {
$(".post-view[data-id]").each((_, el) => {
const $el = $(el);
const id = $el.attr("data-id");
const $counter = $el.find("#postviews").addClass("view-load");
const dbRef = new Firebase(`https://${pvin}-default-rtdb.firebaseio.com/pages/id/${id}`);
dbRef.once("value", snap => {
const data = snap.val() || {
value: 0,
url: location.href,
id: id
};
$counter.removeClass("view-load").text(data.value);
if (document.getElementById("real-post")?.contains(el)) {
data.value++;
dbRef.child("value").set(data.value);
}
});
});
};
document.body.appendChild(s);
});
Here is my rules:
{
"rules": {
".read": true,
".write": true,
}
}

