Additional preview environments support
Configure custom preview URLs to provide editors with seamless access to external preview environments for the Content Delivery API data.
Server-side implementation
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
namespace My.Site;
public class MyUrlProvider : IUrlProvider
{
public string Alias => "MyUrlProvider";
public UrlInfo? GetUrl(IPublishedContent content, UrlMode mode, string? culture, Uri current)
=> null;
public IEnumerable<UrlInfo> GetOtherUrls(int id, Uri current)
=> [];
public async Task<UrlInfo?> GetPreviewUrlAsync(IContent content, string? culture, string? segment)
{
var token = await GetPreviewTokenAsync();
return new UrlInfo(
url: new Uri($"https://my.preview.environment/?id={content.Key}&culture={culture}&token={token}"),
provider: Alias,
culture: culture,
message: null,
isExternal: true);
}
private async Task<string> GetPreviewTokenAsync()
{
// this is where you'll perform auth against the external preview environment and return an auth token
}
}Client-side implementation

Last updated
Was this helpful?