Worker URL Rewrite not working on Bubble.io

I wrote a Worker that is applied to the Worker Route:
*.aholics.com/*

Its job is to rewrite: domain.aholics.comaholics.com/?site=domain

This test page returns the Domain and Site parameter correctly:
https://aholics.com/?site=test

This test page does not, despite the logs (below) looking correct:
https://test.aholics.com
(note the Site parameter is excluded and the Domain isn’t rewritten)

The console logs for my worker seem to be correct, it seems to be creating the correct URL to rewrite to.

  "logs": [
    {
      "message": [
        "Original URL:",
        "https://test.aholics.com/"
      ],
      "level": "log",
      "timestamp": 1713851318452
    },
    {
      "message": [
        "Subdomain:",
        "test"
      ],
      "level": "log",
      "timestamp": 1713851318452
    },
    {
      "message": [
        "New Hostname:",
        "aholics.com"
      ],
      "level": "log",
      "timestamp": 1713851318452
    },
    {
      "message": [
        "New URL:",
        "https://aholics.com/"
      ],
      "level": "log",
      "timestamp": 1713851318452
    },
    {
      "message": [
        "New URL w/ Params:",
        "https://aholics.com/?site=test"
      ],
      "level": "log",
      "timestamp": 1713851318452
    }
  ],

And here’s the Worker code:

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(originalRequest) {
  // Clone the original request to maintain immutability
  const request = new Request(originalRequest);

  // Parse the original request's URL
  const url = new URL(request.url);

  console.log('Original URL:', url); // Log the original URL

  // Extract the subdomain assuming 'subdomain.domain.tld' structure
  const subdomain = url.hostname.split('.')[0]; 

  console.log('Subdomain:', subdomain); // Log the original URL

  if (subdomain === 'www' || subdomain === url.hostname) {
    // Do not rewrite requests for 'www' or the root domain
    return fetch(request);
  }

  // Remove the subdomain from the URL and prepare to add it as a query parameter
  const newHostname = url.hostname.replace(subdomain + '.', '');
  const newUrl = new URL(`${url.protocol}//${newHostname}${url.pathname}`);

  console.log('New Hostname:', newHostname); // Log the original URL
  console.log('New URL:', newUrl); // Log the original URL

  // Add the 'site' query parameter to the URL's search parameters
  newUrl.searchParams.set('site', subdomain);

  console.log('New URL w/ Params:', newUrl); // Log the original URL

  // Construct a new request object with the rewritten URL
  const rewrittenRequest = new Request(newUrl, {
    method: request.method,
    headers: request.headers,
    // Preserve the body if the method isn't GET or HEAD
    body: (request.method !== 'GET' && request.method !== 'HEAD') ? request.body : undefined
  });

  // Fetch and return the response for the rewritten request
  return fetch(rewrittenRequest);

Would LOVE to know what in the world I’m doing wrong. Appreciate the help!

Hey folks, can’t seem to find any answers to this so popping it back up. Would love help on understanding what I’m doing wrong here.

THANK YOU!
Al

Anyone have any time to look at this and at least let me know if I’m doing anything wrong on the Cloudflare side?

THANK YOU!
Al