Problem saving data 2 times in 1 request

When I send a request 1 time to an index.html file that says hello world, the data KV is recorded 2 times, how can I solve this problem?

async function handleRequest(request) {
  // Get the IP address of the incoming user from the request headers
  const ip = request.headers.get("CF-Connecting-IP");
  
  // Generate a 3-digit key
  const key = Math.random().toString().slice(2, 5);
  
  // Save the data to the KV namespace using the generated key
  await LOG_IP.put(`${ip}<${key}`, 8);
  
  // Return the original request
  return fetch(request);
}

addEventListener("fetch", (event) => {
  event.respondWith(handleRequest(event.request));
});
Screenshot_1.png
Was this page helpful?