Using Zyppy With Existing Cloudflare Workers

Zyppy uses Cloudflare Workers to deploy SEO changes to your site. But what if you already have a worker running, for example a custom WordPress Cache? This document will show you how to combine your existing worker code with Zyppy’s HTML rewriting.

Zyppy uses Workers KV to store the SEO changes for your site. Every time you approve a change in our app, we update this data in your Cloudflare account.

After configuring Cloudflare within Zyppy’s Settings, try approving a single SEO change. This will trigger our deploy process to your account. Don’t worry, we won’t overwrite any existing workers or routes.

At this point you should be able to see the Zyppy worker within your Cloudflare Account. Log in, click on “Workers” in the sidebar

You should see “Zyppy” listed here. Click on it, then click on the blue “Quick Edit” link.

Copy and paste the contents of the worker script. This is the latest version of our code so its best to copy it straight from the source.

Your existing code should have code similar to this:

addEventListener("fetch", event => {
 return event.respondWith(handleRequest(event))
})

async function handleRequest(event) {
  // Your custom worker code will be here
}

You will need to combine our handleRequest function with yours, and include all the other code in our worker.

You will also need to bind our Workers KV namespace to your worker. The variable name needs to be PAGES: