Preview configuration
Is this page helpful?
example.org
URL, for example.preview.example.org
URL, for example.https://domain/path
{Space}
: space domain{URLslug}
: content item’s URL slug element value{Lang}
: codename of the selected language{Codename}
: content item’s codename{ItemId}
: content item’s internal ID{Collection}
: content item’s collection codename
{URLslug}
macro: https://preview.example.org/articles/{URLslug}
. Alternatively, you can use the {Codename}
or {ItemId}
macros to identify the content items in your preview URLs.
In multi-regional projects, use the {Lang}
macro to get the currently selected language codename, such as en-us
or ja-jp
.
You can combine the macros. A preview URL https://preview.example.org/{Lang}/articles/{URLslug}
would resolve to https://preview.example.org/en-ca/articles/previewing-content-items
, for example.
https://preview.example.org
would be https://preview.example.org
or https://{Space}
.
<iframe>
within Kontent.ai, you need to ensure a few things:https://preview.example.org
.Content-Security-Policy
header and the frame-ancestors directive: frame-ancestors https://app.kontent.ai
.sandbox
directives using the Content-Security-Policy
header. For example, the directive allow-popups-to-escape-sandbox
allows opening external links, allow-forms
allows submitting forms, allow-downloads
allows downloads after users click a link, and so on.SameSite=None; Secure
.// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
const KontentDelivery = require('@kontent-ai/delivery-sdk');
const deliveryClient = KontentDelivery.createDeliveryClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
previewApiKey: '<YOUR_PREVIEW_API_KEY>',
defaultQueryConfig: {
usePreviewMode: true, // Queries the Delivery Preview API.
}
});
const response = await deliveryClient.item('my_article')
.toPromise();
https://
protocol and URLs accessible to Kontent.ai. Without a valid SSL certificate, Kontent.ai responds with secure connection errors.
When developing apps locally, you can serve pages over HTTPS in combination with ngrok's forwarded address.