A Worker on your site's route. Crawlers (search engines, AI crawlers, link previews) get the page prerendered by Prebaked; visitors get your origin unchanged. Works with any origin behind Cloudflare.
What it does
- Prerenders only
GET/HEADrequests from a known crawler user agent. Static files (.js,.css, images, fonts, ...), other methods and requests carryingX-Prerender(Prebaked's own page fetches) go straight to your origin. - Calls
GET https://service.prebaked.io/<full page URL>with your token inX-Prerender-Token. - Passes Prebaked's 200, redirects, 404 and 410 to the crawler (the page's own status).
- Serves your origin page instead when Prebaked cannot be reached, takes longer than 5 seconds, or answers 401/403 (token or domain problem), 400 or 5xx. Crawlers never see a Prebaked error.
- Sends Prebaked only the crawler's user agent, the token and the visitor IP, never cookies or credentials; a
Set-Cookiefrom Prebaked is not passed on.
1. Copy the files
Into a Worker project (npm create cloudflare@latest, or an existing one):
src/worker.tssrc/prebaked-edge.ts(bot detection, service URL, fallback; no dependencies)wrangler.toml(or merge itsroutesand[vars]into yours)
2. Configure
In wrangler.toml:
main = "src/worker.ts"
routes = [{ pattern = "www.<your-domain>/*", zone_name = "<your-domain>" }]
[vars]
PREBAKED_SERVICE_URL = "https://service.prebaked.io/"Store the token as a secret, not in wrangler.toml:
npx wrangler secret put PREBAKED_TOKEN3. Deploy
npx wrangler deployWithout PREBAKED_SERVICE_URL or PREBAKED_TOKEN the Worker passes every request to your origin.
4. Check it
curl -A "Googlebot" https://www.<your-domain>/ # rendered HTML
curl https://www.<your-domain>/ # your normal pageThe first crawler request appears in the Prebaked dashboard request log.
Notes
- The visitor IP (
CF-Connecting-IP) is sent asX-Forwarded-For, so Prebaked can verify that a request claiming to be Googlebot really comes from Google. - The 5 second limit covers the whole Prebaked response. Cached pages answer well within it.