Endpoint: service.headless-render-api.com
Pre-render/server-side render Path: /$URL
Example URL:
https://service.headless-render-api.com/https://example.com/
The target $URL
is obviously part of the path, but do not re-encode or re-escape it beyond what you'd enter into a browser URL field. Both UTF-8 encoding and percent-encoding are acceptable.
Related links:
This document describes the pre-rendering functionality/endpoint, its associated HTTP header options, and possible error responses.
See the following links for related information:
X-Prerender-Token
curl --header "X-Prerender-Token: secret-token"
You can think of this endpoint almost like a proxy, and in some ways a scraper. It returns the serialized HTML of the requested URL (the "origin") - useful for converting JavaScript apps to their JavaScript + HTML representation instead of just JavaScript.
All of our integration libraries (Node, Nginx, Apache etc.) proxy your requests through this endpoint. It can also be used as a conventional API - but if used as a conventional API, be mindful that the default options are designed to favor it as a proxy endpoint (caches, doesn't follow redirects, includes some server-side rendering compatibility add-ons)
cURL
curl https://service.headless-render-api.com/https://example.com/ > out.html
Standalone Node.js pushstate server w/pre-rendering configured
// 1. build/compile your JavaScript single-page app
// 2. cd into your build/dist directory
npx prerendercloud-server
Node.js HTTP middleware
// npm install prerendercloud
const app = require('express')();
const prerendercloud = require('prerendercloud');
app.use(prerendercloud);
See more low-level examples, or see high-level pre-rendering docs.
How various content-types are handled:
400
Status codes
Controlling status codes
Prerender-Follow-Redirects
header and the submitted URL returns 301/302, the service will follow the redirects and return final status code<meta name="prerender-status-code" content="xxx">
, the service will return the specified code (scroll down to read more)prerender-disable-cache
curl --header "Prerender-Disable-Cache: true"
prerender-cache-duration
curl --header "Prerender-Cache-Duration: 2592000"
prerender-recache
curl --header "Prerender-Recache: true"
prerender-disable-ajax-preload
curl --header "Prerender-Disable-Ajax-Preload: true"
prerender-disable-ajax-bypass
curl --header "Prerender-Disable-Ajax-Bypass: true"
prerender-disable-head-dedupe
curl --header "Prerender-Disable-Head-Dedupe: true"
prerender-wait-extra-long
{ waitUntil: 'networkidle' }
. Useful for
pages that depend on AJAX/XHR that fire late or IPFS hosted pagescurl --header "Prerender-Wait-Extra-Long: true"
prerender-dont-wait-for-web-sockets
curl --header "prerender-dont-wait-for-web-sockets: true"
prerender-block-cookies
curl --header "prerender-block-cookies: true"
origin-header-whitelist
curl --header "origin-header-whitelist: prerendercloud-whatever,prerendercloud-b" \
--header "prerendercloud-whatever: some-value \
--header "prerendercloud-b: some-other-value"
prerender-meta-only
curl --header "Prerender-Meta-Only: true"
prerender-remove-script-tags
curl --header "prerender-remove-script-tags: true"
prerender-remove-trailing-slash
curl --header "prerender-remove-trailing-slash: true"
prerender-follow-redirects
curl --header "Prerender-Follow-Redirects: true"
prerender-device-width
curl --header "prerender-device-width: 800"
prerender-device-height
curl --header "prerender-device-height: 600"
prerender-device-is-mobile
curl --header "prerender-device-is-mobile: true"
prerender-with-screenshot
This is useful for savings screenshots or injecting them as open graph
images. Often used with Prerender-With-Metadata
curl --header "Prerender-With-Screenshot: true"
prerender-with-metadata
This is useful for capturing SEO-relevant metadata during the pre-render.
curl --header "Prerender-With-Metadata: true"
Controlling Status Codes
<meta name="prerender-status-code" content="404">
<meta name="prerender-status-code" content="301">
<meta name="prerender-header" content="Location: http://www.example.com">
(note: no other headers, currently, can be modified like this)Our official libraries are configured to propogate 400
errors to what a visitor of your website would see, but the libraries are (or should be) configured to hide rate limiting (429
) and 5xx
errors and fallback to non-prerendered content.
400
content-type: application/octet-stream
429
500
502
503
504