Menu

Prerender service down or timing out? Make prerender-node fall back to your own page
📰

Prerender service down or timing out? Make prerender-node fall back to your own page

DEV Community: react·Markus Delos Santos·3 days ago
#Rpm7E4qS
#devtoreact#devto#dev#prerender#service
Long article (1237 words) — no AI summary yet.
Reading 0:00
15s threshold

If your prerender service times out or goes down, prerender-node won't switch to your normal page on its own. If the service sends back an error status, such as a 504, the crawler gets that same status. The fix is a few lines in the afterRender hook. Return { cancelRender: true } when the render failed, and the request skips to your next middleware, which serves your own page.

What prerender-node does with a failed render

Here's the normal path. The middleware checks the user agent string against a default list of crawler user agents. Then it asks your prerender service for the page's prerendered HTML and returns that HTML from your server. Unless you set PRERENDER_SERVICE_URL, it uses the service already deployed by Prerender.io.

A render can fail in two ways, and the middleware handles them differently. In the first, the service answers with an error status. prerender-node writes the service's status code and headers straight to the response the crawler gets.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.