Previews#
The Preview button in Velora's editor opens a draft on your real site, so editors see it exactly as readers will. It sends the editor to your Preview URL (Connect) with a signed link:
https://your-site.com/api/preview?article=<article id>&exp=<unix seconds>&sig=<hex>
articleis the article's id, a UUID.expis when the link stops working, in Unix seconds. Links last 24 hours.sigis the hex HMAC-SHA256 of the stringpreview:<article id>:<exp>, keyed with the webhook secret. It has nosha256=prefix.
No Preview button appears until the Preview URL is set.
Check the link#
Before showing anything:
- Check
articleis a UUID andexpis digits. - Check
exphas not passed. - Compute
preview:<article>:<exp>with the webhook secret and compare it withsigin constant time. - Answer
401if any check fails.
import { createHmac, timingSafeEqual } from "node:crypto";
export function validPreview(article: string, exp: string, sig: string, secret: string): boolean {
if (!/^\d{1,12}$/.test(exp) || Number(exp) < Date.now() / 1000) return false;
const expected = Buffer.from(createHmac("sha256", secret).update(`preview:${article}:${exp}`).digest("hex"));
const given = Buffer.from(sig.toLowerCase());
return expected.length === given.length && timingSafeEqual(expected, given);
}
Read the draft#
Pass the same sig and exp on to the preview route, with the read key:
curl -H "Authorization: Bearer $VELORA_READ_KEY" \
"https://delivery.velora.build/$SITE_ID/preview/$ARTICLE_ID?sig=$SIG&exp=$EXP"
Velora checks the signature again and answers the draft as an ArticleDetail, the same shape as a published article, with an empty related list. An expired or wrong link answers 404. Nothing about it is written or cached anywhere.
Show it#
- Render it with your article page, so the preview is faithful.
- Never cache it, and keep it out of search engines (
noindex). - Show a clear banner, so nobody mistakes a draft for the published page.
- Give the preview its own route, kept for your front end (Velora keeps
/previewby default; see Routing). If your framework has a draft mode, the preview handler can turn it on and redirect to that route, carryingsigandexpwith it.
This page as markdown: https://developers.velora.build/previews.md