Use the official, unmodified prerender-node middleware and point it at Prebaked. Only the service URL and the token change. Protocol details: docs/protocol.md.
1. Install
npm install prerender-node2. Add the middleware before your static files and SPA routes
const express = require('express');
const prerender = require('prerender-node');
const app = express();
app.use(
prerender
.set('prerenderServiceUrl', 'https://service.prebaked.io/')
.set('prerenderToken', process.env.PREBAKED_TOKEN),
);
app.use(express.static('dist'));
app.get('/{*path}', (req, res) => res.sendFile('index.html', { root: 'dist' }));Instead of set(...) you can use the environment variables the middleware already reads:
PRERENDER_SERVICE_URL=https://service.prebaked.io/
PRERENDER_TOKEN=<your token>Use https://: Prebaked refuses plain http:// calls with 403. Mount the middleware on the app root (app.use(prerender)), not inside a sub-router, so the full path is sent.
3. Recommended: serve your own page if Prebaked fails
By default prerender-node passes every Prebaked answer to the crawler, including 401/403 (wrong token, domain not verified yet) and 5xx, and answers 500 if Prebaked cannot be reached. It also has no timeout. Add the documented afterRender hook so crawlers only ever see your page's own status:
prerender.set('afterRender', (err, req, prerenderRes) => {
const status = prerenderRes?.statusCode ?? 0;
const pageStatus = (status >= 200 && status < 400) || status === 404 || status === 410;
if (err || !pageStatus) return { cancelRender: true };
});With it, an unreachable Prebaked, 400, 401, 403 and 5xx serve your normal page. 200, redirects, 404 and 410 are the rendered page's own status and still reach the crawler.
4. Recommended: AI crawlers missing from prerender-node 3.8.3
prerender-node 3.8.3 (the current npm release) does not recognise these crawlers that Prebaked supports, so they would get your empty SPA shell. Add them:
prerender.addUserAgents(['OAI-SearchBot', 'ClaudeBot', 'Claude-User', 'meta-externalagent']);This list is checked against Prebaked's bot list by test/recommended-setup.test.ts.
5. Behind a proxy or CDN
The page URL sent to Prebaked is built from X-Forwarded-Proto and X-Forwarded-Host (or Host). If your proxy does not set them, fix the values:
prerender.set('protocol', 'https').set('host', 'www.<your-domain>');6. Check it
curl -A "Googlebot" https://www.<your-domain>/ # rendered HTML
curl https://www.<your-domain>/ # your normal SPA shellThe first request appears in the Prebaked dashboard request log.