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 Java SDK at https://kontent.ai/learn/java
import kontent.ai.delivery.*;
// Initializes a DeliveryClient for preview
DeliveryClient client = new DeliveryClient(
DeliveryOptions.builder()
.projectId("<YOUR_ENVIRONMENT_ID>")
.previewApiKey("<YOUR_PREVIEW_API_KEY>")
.usePreviewApi(true)
.build();
);
// Tip: Create strongly typed models according to https://kontent.ai/learn/strongly-typed-models
// Registers the model class for articles
client.registerType(Article.class);
// Gets the latest version of an item
CompletionStage<Article> article = client.getItem(
"my_article",
Article.class
);
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.