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-Tokencurl --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.htmlStandalone 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-serverNode.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:
400Status 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-cachecurl --header "Prerender-Disable-Cache: true"prerender-cache-durationcurl --header "Prerender-Cache-Duration: 2592000"prerender-recachecurl --header "Prerender-Recache: true"prerender-disable-ajax-preloadcurl --header "Prerender-Disable-Ajax-Preload: true"prerender-disable-ajax-bypasscurl --header "Prerender-Disable-Ajax-Bypass: true"prerender-disable-head-dedupecurl --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-socketscurl --header "prerender-dont-wait-for-web-sockets: true"prerender-block-cookiescurl --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-onlycurl --header "Prerender-Meta-Only: true"prerender-remove-script-tagscurl --header "prerender-remove-script-tags: true"prerender-remove-trailing-slashcurl --header "prerender-remove-trailing-slash: true"prerender-follow-redirectscurl --header "Prerender-Follow-Redirects: true"prerender-device-widthcurl --header "prerender-device-width: 800"prerender-device-heightcurl --header "prerender-device-height: 600"prerender-device-is-mobilecurl --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-metadataThis 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.
400content-type: application/octet-stream429500502503504