Cloudflare

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.

  1. Select your site on the Cloudflare dashboard. Cloudflare dashboard
  2. Navigate through Workers -> Manage workers -> Create a worker.
  3. 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.Cloudflare dashboard
  4. Replace your API_KEY value with your actual API key from the Prerender.io dashboard, and edit the PRERENDERED_DOMAINS array to match your site configuration. Please use exact, lowecase domains. No wildcards allowed here. If you need to use wildcards, you can freely alter the part of the code that is responsible for the selection.Cloudflare dashboard

Note: Do not send a test request yet, as the site mapping is not yet done. We'll do that later.

  1. Click Save and Deploy and navigate back to your workers as explained in step 2, but instead of clicking Manage workers, click Add route.
  2. 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. Cloudflare dashboard
  3. Click save and you should be good to go!

Note: 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 PRERENDERED_DOMAINS array).

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.