Cloudflare Worker Reverse Proxy Not Working

I have a worker i’ve deployed to enable a reverse proxy under my subdomain.

I have the route for it setup as .domain.com/app/

The code for the worker is–

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

async function handleRequest(request) {
  var url = new URL(request.url)

  url.hostname = "other.uc.r.appspot.com"
  return await fetch(url, request)
}

In the worker quick edit, i’ve validated that this works.

However, when i make requests to domain.com/app/anything, it never routes the traffic to the worker.

1 Like

From the example you’ve given, you have it mapped to only sub domains but you are not requesting a sub domain. Which is exactly why it wouldn’t be called.

If you need further help, please share your domain and the exact mapping you’re doing.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.