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 .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
// Tip: Use DI to create Delivery client https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
.WithOptions(builder => builder
.WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3")
.UsePreviewApi("<YOUR_PREVIEW_API_KEY>")
.Build())
.Build();
// Gets the latest version of a content item
// Tip: Create strongly typed models according to https://kontent.ai/learn/net-strong-types
IDeliveryItemResponse<Article> response = await client.GetItemAsync<Article>("my_article");
Article item = response.Item;
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.