Worker route not being matched for reverse proxy

I’m following this guide Guide: How to Reverse Proxy with Cloudflare Workers

I’ve got a domain at domain.com as well as a subdomain at blog.domain.com both on Cloudflare that route to webflow. I’d like to set up a reverse proxy to have domain.com/blog serve the contents of blog.example.com.

I’ve created a worker that does:

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
var url = new URL(request.url)
url.hostname = "blog.domain.com"
console.log(request);

let response = await fetch(url, request)
return response;
}

When I hit my worker url, I can see in the log stream the content of the request. I’ve attached a route to my domain.com that maps domain.com/blog* to the worker. However, hitting any of those URLs results in my domain.com's normal 404 page. Likewise, I don’t see any logs which leads me to believe that the worker route is not being matched.

For this specific example, I am not proxying any requests through Cloudflare (orange cloud button) and am still using webflow’s SSL.

Cloudflare’s worker won’t be able to run on your domain if the requests for it never arrive at Cloudflare in the first place. You’ll have to enable Cloudflare’s proxy (:orange:) if you want your Cloudflare Worker to get executed on that route.

1 Like

That makes sense. I tried proxying the subdomains, the www CNAME and the A record but all had the same result.

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