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.
admaxxer.com may be blocked by uBlock Origin, Brave, and similar tools. Requests to yourdomain.com are not.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.
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);
},
};
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.
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.
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.
*, not regex. Make sure your domain is proxied (orange cloud), not DNS-only (grey cloud).Access-Control-Allow-Origin: * in the worker response headers if your pixel loads cross-origin. Most setups don't need this.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.
Vercel · Next.js · Nuxt · Netlify · WordPress · Apache · NGINX
See also: Connections › Install for the base snippet.