<p>Since <a href="https://github.com/craftcms/cms/blob/develop/CHANGELOG-v3.md#331---2019-09-06" rel="nofollow noreferrer">Craft 3.3.1</a>, you can create a custom <a href="https://docs.craftcms.com/v3/config/#aliases" rel="nofollow noreferrer">alias</a> that resolves to your frontend base URL, and add that alias to the relevant <a href="https://docs.craftcms.com/v3/sections-and-entries.html#preview-targets" rel="nofollow noreferrer">preview targets'</a> "URL Format" setting.</p>

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

<pre class="lang-php prettyprint-override"><code>'aliases' =&gt; [
    '@previewBaseUrl' =&gt; 'https://domain.com',
],
</code></pre>

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

CC BY-SA 4.0
2019-12-29T05:31:55.033Z
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
CC BY-SA 4.0
2019-12-28T20:55:05.387Z
2019-12-28T21:05:35.910Z
2019-12-28T21:05:35.910Z
Mats Mikkel Rummelhoff
<p>I will be using CraftCMS (Craft Solo 3.3.18.4) in headless mode as the backend for a Rails app. The Craft instance lives on a different subdomain.</p>

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

<p>For example, if we presume
<code>admin.domain.com</code> for craft admin and
<code>domain.com</code> for the front end</p>

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

<live-preview><headless>
Headless CraftCMS: How can I tell Craft to load live preview from a different (sub)domain?
# Headless CraftCMS: How can I tell Craft to load live preview from a different (sub)domain?

(Asked by: username_0 on 2019-12-27)

I will be using CraftCMS (Craft Solo 3.3.18.4) 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...`

**Tags:** live-preview, headless

---

## 1 answers

### Answer by username_1 on 2019-12-28. Score: 3

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}

> **Comments:**
> **username_0**: 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.  

---

