Cloudflare Worker Routing

Hello All,

I’m setting up a worker to proxy from a subdomain to the main URL of a site, the proxy functionality works when going from blog.example.com to blog2.example.com but not with the routes for example.com/blog. I’ve attached some screenshots and the script below, any help or ideas would be great.

addEventListener('fetch', event => {

event.respondWith(handleRequest(event.request))
})

/**

  • Respond to the request
  • @param {Request} request
    */
    async function handleRequest(request) {
    let newURL = new URL(request.url)
    newURL.hostname = ‘blog.5050.wtf’
    request = new Request(newURL, request)

return await fetch(request)
}


Many thanks
Josh