Cloudflare working in preview but not on the live web

I have a website here at the root domain which I do not want affected by the worker

I would like to pull content from here

and serve it over the route configured here:


Buy Candy

My worker looks like the following:

addEventListener(‘fetch’, event => {
** event.respondWith(handleRequest(event.request))**

async function handleRequest(request) {

** const url = new URL(request.url)**
** const path = url.pathname**
** const parts = path.split(‘/’)**
** // Get the URL after the first slash**
** const durl = parts[2]**
** const basePath = ‘’ + durl + ‘/index.html’;**
** const originalResponse = await fetch(basePath);**

** const originalHTML = await originalResponse.text();**
** const modifiedHTML = originalHTML.replace(//, ‘’);**

** // Create a new response with the modified HTML**
** const newResponse = new Response(modifiedHTML, originalResponse);**
** newResponse.headers.set(‘Content-Type’, ‘text/html’);**

** return newResponse;**

This works fine in the preview but does not render in a browser.

i have cleared all cache, checked and upgrade any SSL certs.

The website is hosted on WP Engine, could there be any issues here?

Any help is much appreciated!