<p>I had the same issue! </p>

<p>In my case, it was because I had defined <code>http://example.com</code> as my <code>siteUrl</code> for the production environment, in my <code>general.php</code> config file. Simply changing this to <code>https://example.com</code> fixed it! </p>

<p>Sample code: <em>(Change 'production' to match the env you are targeting of course)</em></p>

<pre><code>'production' =&gt; [
    // Base site URL (if multisite)
    'siteUrl' =&gt; [
        'mysite!' =&gt; 'https://example.ca',
    ],
    //OR Base site URL (if single site)
    'siteUrl' =&gt; 'https://example.ca'
],
</code></pre>

<p>More on the <code>general.php</code> config file: <a href="https://docs.craftcms.com/v3/config/config-settings.html" rel="nofollow noreferrer">https://docs.craftcms.com/v3/config/config-settings.html</a></p>

CC BY-SA 4.0
2019-09-11T15:08:50.320Z
2019-09-11T15:08:50.320Z
stojda
<p>My live preview isn't loading. I'm getting the following error:</p>

<p>Mixed Content: The page at '<a href="https://www.site.com/admin/entries/pages/611-title" rel="nofollow noreferrer">https://www.site.com/admin/entries/pages/611-title</a>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '<a href="http://www.site.com/path/title?token=lxDnfeMzRFOM-xI2IylUQZ2r1XkiQlgR" rel="nofollow noreferrer">http://www.site.com/path/title?token=lxDnfeMzRFOM-xI2IylUQZ2r1XkiQlgR</a>'. This request has been blocked; the content must be served over HTTPS</p>

<p>I'm not sure where the http request is coming from though. My env file sets the site url using https, and the Base URL in settings > sites also uses https. Is there another location where Craft could be getting the http from?</p>

<p>UPDATE: I tweaked my htaccess settings, and now I'm getting a different error:
[Error] Failed to load resource: the server responded with a status of 500 () (page-title, line 0) <a href="https://www.example.com/path/page-title?token=zVyQLpLN9K8fZ9FJKYf6Y6l9gEvHAWts" rel="nofollow noreferrer">https://www.example.com/path/page-title?token=zVyQLpLN9K8fZ9FJKYf6Y6l9gEvHAWts</a>
If I try to access the url in the error, I get a HTTP 400 – Bad Request – yii\web\BadRequestHttpException error</p>

CC BY-SA 4.0
2019-04-11T23:29:38.253Z
Maybe a rewrite in the .htaccess file?
Brad Bell
CC BY-SA 4.0
2019-04-12T18:48:33.260Z
@BradBell I updated my .htaccess and now I'm getting a 500 error (see update to my original post)
artmem
<live-preview><xmlhttprequest>
Live Preview not loading - https / http conflict
# Live Preview not loading - https / http conflict

(Asked by: username_0 on 2019-04-11)

My live preview isn't loading. I'm getting the following error:

Mixed Content: The page at '<https://www.site.com/admin/entries/pages/611-title>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '<http://www.site.com/path/title?token=lxDnfeMzRFOM-xI2IylUQZ2r1XkiQlgR>'. This request has been blocked; the content must be served over HTTPS

I'm not sure where the http request is coming from though. My env file sets the site url using https, and the Base URL in settings > sites also uses https. Is there another location where Craft could be getting the http from?

UPDATE: I tweaked my htaccess settings, and now I'm getting a different error:
[Error] Failed to load resource: the server responded with a status of 500 () (page-title, line 0) <https://www.example.com/path/page-title?token=zVyQLpLN9K8fZ9FJKYf6Y6l9gEvHAWts>
If I try to access the url in the error, I get a HTTP 400 – Bad Request – yii\web\BadRequestHttpException error

**Tags:** live-preview, xmlhttprequest
> **Comments:**
> **username_1**: Maybe a rewrite in the .htaccess file?  
> **username_0**: @BradBell I updated my .htaccess and now I'm getting a 500 error (see update to my original post)  

---

## 1 answers

### Answer by username_2 on 2019-09-11. Score: 1

I had the same issue! 
In my case, it was because I had defined http://example.com as my siteUrl for the production environment, in my general.php config file. Simply changing this to https://example.com fixed it! 
Sample code: (Change 'production' to match the env you are targeting of course)
'production' => [
    // Base site URL (if multisite)
    'siteUrl' => [
        'mysite!' => 'https://example.ca',
    ],
    //OR Base site URL (if single site)
    'siteUrl' => 'https://example.ca'
],

More on the general.php config file: https://docs.craftcms.com/v3/config/config-settings.html


---

