Our Cloudflare integration uses a simple worker implementation that routes requests between your site (probably your cached site) and Prerender.io based on some logic. Here is how you get started with Prerender.io on Cloudflare:
The install guide assumes that you already have a site hosted through Cloudflare.
Workers -> Manage workers -> Create a worker.
Copy and paste the content of index.js from the Cloudflare example over the code editor on the left-hand side, overwriting its current content.
- Replace your
API_KEYvalue with your actual API key from the Prerender.io dashboard, and edit the
PRERENDERED_DOMAINSarray to match your site configuration. Please use exact, lowercase domains. No wildcards are allowed here. If you need to use wildcards, you can freely alter the part of the code responsible for the selection.
Note: Do not send a test request yet, as the site mapping is not yet done. We'll do that later.
Save and Deployand navigate back to your workers as explained in step 2, but instead of clicking
Manage workers, click
- Edit your route to match your site config (e.g.
example.com/*to cover your whole site on the Apex domain, or
*.example.com/*if you want to cover all subdomains too). Make sure you select the worker that you previously created.
- Click save, and you should be good to go!
Optionally, you can now go back to test or debug your worker as shown in step 3, but remember to replace the entire worker URL with your actual site URL (or add your worker URL to the