async function handleRequest(req) {
  // Load the url into a JavaScript URL object
  const url = new URL(req.url)

  // Split the pathname by period, pop off the last section (if there is one) and lowercase it to get the file extension
  const ext = url.pathname.split('.').pop().trim().toLowerCase();

  // Check if that file extension is in the list of bad file extensions
  const badFileExtensions = ["exe", "dll", "zip"];
  if (badFileExtensions.includes(ext)) {
    // Bad file extension found, return a 403 error
    return new Response("Forbidden", {
       status: 403
      }
    );
  }

  // If not blocked, let the request pass through to the origin
  const backendResponse = fetch(req, {
    backend: "origin_0"
  });

  return backendResponse;
}

addEventListener("fetch", (event) => event.respondWith(handleRequest(event.request)))