Use workers to build a simple reverse proxy to mask URls

We use a third-party service (so we don’t control the host) alongside our own services offered to developers.

To make it easier, we want them all accessible under the same root domain https://api.ourdomain.com

We want to forward and passthrough all of the paths and resources, so that, for example, ‘https://api.ourdomain.com/base_url/resource’ passes requests to ‘https://api.otherservice.com/base_url/resource

How could I do this?

2 Likes

You want to proxy the requests to a backend, via fetch.

Look at the examples in the Cloudflare Workers documentation