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.