Skip to main content

How to Set Up a Reverse Proxy to PartnerPage with Cloudflare Workers

Use Cloudflare Workers to customize your directory URL to seem as if it's part of your site, such as yourdomain.com/experts

R
Written by Roberto Carozza
Updated over a month ago

You can serve your PartnerPage-hosted directory under your own domain (e.g. yourdomain.com/partner-directory/) by using Cloudflare Workers. This keeps users on your domain while loading content from your PartnerPage instance.

✅ Requirements

  • Your domain is using Cloudflare

  • You have Cloudflare Workers enabled (included in most paid plans)

  • You want to serve a directory under a path like /partner-directory/ or /integrations-directory/

  • Your know your PartnerPage base URL (e.g. https://<your-id>.directory.sites.partnerpage.io or <yourcompany>.partnerpage.io)

1: Add a Cloudflare Worker

  1. Select the domain you’d like to use

  2. Navigate to Workers & Pages > Workers

  3. Click “Create Worker”

This will open the Cloudflare Worker editor.

Step 2: Add the PartnerPage Proxy Script

Paste the following script into the Worker editor:

addEventListener("fetch", event => {
const requestURI = new URL(event.request.url);

if (
requestURI.hostname === "yourdomain.com" && // replace with your actual domain
(requestURI.pathname.startsWith("/partner-directory/") ||
requestURI.pathname.startsWith("/integrations-directory/"))
) {
event.respondWith(rewriteProxyURL(event.request));
}
});

async function rewriteProxyURL(request) {
const originalURI = new URL(request.url);
const newURI = new URL(request.url);

newURI.protocol = "https:";
newURI.hostname = "yourname.partnerpage.io"; // replace with your PartnerPage subdomain
newURI.pathname = originalURI.pathname;

const clientIP = request.headers.get("cf-connecting-ip");

const headers = new Headers(request.headers);
headers.set("PartnerPage-Client-IP", clientIP);
headers.set("PartnerPage-Reverse-Proxy", "true");

return fetch(newURI.toString(), {
method: request.method,
headers: headers,
body: request.body,
redirect: "follow"
});
}

Make sure to replace both lines below

 requestURI.hostname === "yourdomain.com" && 

newURI.hostname = "yourname.partnerpage.io";

With your actual PartnerPage domain (you can find this in your PartnerPage admin or onboarding instructions).

3: Assign a Route to the Worker

Once your script is saved:

  1. Go to the “Triggers” tab in your Worker

  2. Add a route that matches the path you want to proxy, e.g.

yourdomain.com/partner-directory/*

This route tells Cloudflare to invoke your Worker whenever someone visits that path.

4. Review your configuration

To successfully proxy your PartnerPage directory using Cloudflare Workers, make sure you have:

  • ✅ A Cloudflare Worker that:

    • Matches your desired path (e.g. /partner-directory/ or /integrations-directory/)

    • Forwards the request to your PartnerPage subdomain

    • Sets the required headers below

  • ✅ A route like yourdomain.com/partner-directory/* bound to the Worker

  • ✅ The following required headers included in the request:

    • PartnerPage-Reverse-Proxy: true

    • PartnerPage-Client-IP: <visitor IP from cf-connecting-ip>

These headers are required for PartnerPage to accept and respond to proxy traffic properly. Without them, requests may be rejected or fail to load.

Once configured, your PartnerPage content will appear seamlessly under your domain with full functionality.

Need help? Reach out to PartnerPage support anytime.

Did this answer your question?