I will be using CraftCMS (Craft Solo in headless mode as the backend for a Rails app. The Craft instance lives on a different subdomain.

How do I instruct craft to use the rails app URI when loading live preview in the preview iframe?

For example, if we presume admin.domain.com for craft admin and domain.com for the front end

How do I make the live preview frame to load from the live app? domain.com/posts/first-posts-slug?x-craft-live-preview=2OcHezCnU8&token=lY6F...


Since Craft 3.3.1, you can create a custom alias that resolves to your frontend base URL, and add that alias to the relevant preview targets' "URL Format" setting.

For example, assuming you put something like the below in your config/general.php file:

'aliases' => [
    '@previewBaseUrl' => 'https://domain.com',

...you'd be able to use that @previewBaseUrl alias in your preview targets, e.g. @previewBaseUrl/posts/{slug}

  • Thank you, I'll try this. I need to modify the default preview target which gets pulled in an iframe when I click the preview button. Will report if this works.
    – aaandre
    Dec 29 '19 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.