Hooking into preview

Our entire website is behind login, so whenever we try to preview we get redirected to login page.

While we could log in and then click preview, I would like to hook into an event, so if the request is a preview request, then i want to log in the member using our test user.

Is there an event to hook into this?

I suspect your frontend logins somehow clashes with your backoffice logins? Otherwise, why don’t your editors log in on the frontend first so they can actually do previews?

Is this a headless site or a monolith?

If it’s all hosted in the one Umbraco instance then Umbraco already knows if it’s a preview request - just check the context (UmbracoContext.InPreviewMode) and log the user in when they hit the page.

If it’s headless, you can use the SendingContentNotification to add an extra preview URL.

Additional preview environments support | Umbraco CMS

1 Like

Yeah it was to avoid that, they are doing that for now.

The real reason is that i recently installed uSync.Complete which has a crafty feature of showing content differences using the Preview, but this would require my editors to log into both of our websites to see any content difference (except for the JSON difference).

Monolith site, I did not know that, I will try that and return, thanks :slight_smile: