Proxy Admaxxer Through Cloudflare Workers

Running /js/script.js and /api/event through your own domain closes the gap that most browser-based ad blockers exploit: they block requests to known third-party tracking hostnames, not to your own domain. A Cloudflare Worker lets you relay those two paths on the edge — zero latency added, no origin server needed.

Why Proxy the Pixel?

Prerequisites

Step 1 — Create the Worker

In the Cloudflare dashboard go to Workers & Pages › Create application › Create Worker. Name it admaxxer-proxy and deploy the default hello-world script first so you have a worker to edit.

Step 2 — Paste the Worker Script

Open the worker editor and replace the entire script with:

const UPSTREAM = 'https://admaxxer.com';

export default {
  async fetch(request) {
    const url = new URL(request.url);

    // Only proxy the two Admaxxer paths; pass everything else through
    if (
      url.pathname === '/js/script.js' ||
      url.pathname.startsWith('/api/event')
    ) {
      const target = new URL(url.pathname + url.search, UPSTREAM);
      const proxied = new Request(target.toString(), {
        method: request.method,
        headers: request.headers,
        body: request.method !== 'GET' ? request.body : undefined,
        redirect: 'follow',
      });
      return fetch(proxied);
    }

    // All other paths are served by your origin
    return fetch(request);
  },
};

Step 3 — Add a Route

In the worker settings click Triggers › Add route. Enter:

yourdomain.com/js/script.js
yourdomain.com/api/event*

Set the Zone to your domain. Save. Cloudflare will now send matching requests to the worker instead of your origin server.

Step 4 — Update the Snippet in Admaxxer

Go to Connections › Install and enable Custom proxy domain. Enter https://yourdomain.com. Admaxxer regenerates the snippet so that script.js and /api/event resolve to your domain.

Step 5 — Test

Open a browser DevTools Network tab and reload your site. You should see a 200 for https://yourdomain.com/js/script.js and a 200 (or 204) for /api/event POST requests. Then run:

curl -I https://yourdomain.com/js/script.js

Expect: HTTP/2 200, content-type: application/javascript.

Troubleshooting

Rollback

Delete the route in Workers › Triggers or set the worker to return fetch(request) unconditionally. Then in Admaxxer disable the custom proxy domain to revert the snippet to pointing at admaxxer.com.

Other Proxy Guides

Vercel · Next.js · Nuxt · Netlify · WordPress · Apache · NGINX

See also: Connections › Install for the base snippet.