Redirect loops
Last reviewed
Prebaked does not create redirects. It passes your page's own redirect, with its Location header, to the crawler. So a redirect loop that crawlers hit almost always exists for people too, and comes from your Cloudflare SSL/TLS mode or from www and apex redirects that point at each other.
Find the loop
Follow the redirects with curl, once as a crawler and once as a person:
curl -sIL -A "Googlebot" --max-redirs 5 https://example.com/ | grep -iE "^(HTTP|location)"
curl -sIL --max-redirs 5 https://example.com/ | grep -iE "^(HTTP|location)"
A loop shows the same Location values again and again until curl stops. Run the same commands for https://www.example.com/ and http://example.com/.
Cause 1: Cloudflare SSL/TLS mode is Flexible
In Flexible mode, Cloudflare talks to your server over plain http. If your server redirects http to https, it sends every request back to https, Cloudflare asks over http again, and the loop never ends. Browsers show "too many redirects".
Fix: in Cloudflare, open SSL/TLS and set the mode to Full or Full (strict). Your server needs a certificate for this; Full (strict) needs a valid one. Then run the curl commands again.
Prebaked renders the public URL of your page, so it gets the same redirect as everyone else and passes it on to the crawler.
Cause 2: www and apex redirect to each other
Pick one main host, for example www.example.com, and redirect only the other one to it. A loop happens when two settings disagree: for example a Cloudflare redirect rule sends www to the apex while your host or framework sends the apex to www.
Fix: keep one redirect rule. Check Cloudflare redirect rules, your hosting provider's domain settings and your framework's config.
Prebaked treats example.com and www.example.com as one domain with one token, and the Cloudflare install adds routes for both. The host that redirects simply passes its redirect on to the crawler, which then requests the main host.
Cause 3: Prebaked's own requests come back to Prebaked
When Prebaked renders a page, its requests to your site carry the header X-Prerender: 1. All Prebaked integrations send such requests straight to your site. If a custom setup sends them to Prebaked again, Prebaked answers 508 with the message Loop detected, and the integrations then serve your own page.
Fix: in custom middleware or proxy rules, skip prerendering for every request that has an X-Prerender header.
Not a loop: http calls to the service
A service URL with plain http:// is refused with 403, not redirected. See 401 and 403 errors.
FAQ
Does Prebaked follow redirects?
No. It passes your page's redirect status and Location header on to the crawler, which then requests the new URL.
Which Cloudflare SSL/TLS mode should I use with Prebaked?
Full or Full (strict). Flexible mode loops when your server redirects http to https.
Do I need separate setups for www and the apex?
No. example.com and www.example.com are one domain with one token, and the Cloudflare install adds routes for both.
What does 508 Loop detected mean?
A request with an X-Prerender header reached Prebaked, so your setup is sending Prebaked's own page fetches back to it. Skip prerendering for every request with that header.
Does an http service URL get redirected to https?
No. Prebaked refuses plain http:// calls with 403. Change the service URL to https://service.prebaked.io/.