Worker code works in Cloudflare editor but doesn't work in production

Hi everyone.

I’ve setup a simple worker example that makes a GET fetch() call to one my URLs I control that deletes an entry inside MongoDB.

The code works inside Cloudflare’s browser editor just fine. The test entry gets deleted in MongoDB.
However, when I run the URL in the browser, it never works. The test entry in MongoDB still exists and never gets deleted.

Everything on MongoDB works just fine including IP address whitelisting.

I’ve tried assigning a domain name to the worker route and just using the raw worker route URL but the code does not execute. There’s no errors in the console either.

I’m pretty sure this is not a code problem but something else I’m missing in Cloudflare.
I’ve tried everything and looked over all the documentation and support forums and cannot get this to work.

Any suggestions from anyone?

export default {
  async fetch(request, env) {
    var urldata = request.url.split("unsubscribe?")[1];
    var email = urldata.split("email=")[1].split("&t=")[0]

    const url = "" + email;

    async function gatherResponse(response) {
      const { headers } = response;
      const contentType = headers.get('content-type') || '';
      if (contentType.includes('application/json')) {
        return JSON.stringify(await response.json());
      } else if (contentType.includes('application/text')) {
        return response.text();
      } else if (contentType.includes('text/html')) {
        return response.text();
      } else {
        return response.text();

    const response = await fetch(url);
    const results = await gatherResponse(response);
    return new Response("results");