# HTTPS support - Error Embedding

**URL:** https://meta.discourse.org/t/https-support-error-embedding/68944
**Category:** Support
**Created:** [August 28, 2017, 5:48pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944 "2017-08-28T17:48:57Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![spectrum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spectrum/32/142226_2.png) [@spectrum](https://meta.discourse.org/u/spectrum)
#### Post date: [August 28, 2017, 5:48pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/1 "2017-08-28T17:48:57Z")

</div>

Hi,  
I have been testing implementing HTTPS for a production site that uses Discourse for comments.  
Comments show up on `http://sitename.tld`, but not on `https:// sitename.tld`. The URL for our Discourse site is `https:// discussion.sitename.tld`; the Discourse site has already been working with HTTPS for a while now.

I did some digging and found that we’re linking to a JavaScript file over HTTP, at `http://discussion.sitename.tld/javascripts/embed.js`. When I change our configuration like below, I see an “Error Embedding” message upon viewing `https://sitename.tld.`

```
  var discourseUrl = "https:// discussion.sitename.tld/",
      discourseEmbedUrl = "<?php print 'https:// sitename.tld/node/'.$node->nid; ?>";

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
      d.src = discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
  })();

```

The one time I did get this semi-working was from changing the d.src variable to be a direct link, like so:  
`d.src = 'https:// discussion.sitename.tld/javascripts/embed.js';`

I also changed a few settings in Discourse under Security, by adding `https://sitename.tld` to the list of CORS I believe. I added `https://sitename.tld` to the list on Customizations-\>Embedding as well. This resulted in multiple new topic creations on discussion.sitename.tld; instead of using already-created topics that were made over HTTP connection to the site, it created new topics for each of the pages and flooded our forum for a bit… ☹

Is there a better way I can set this up so the comments show up on our site from HTTPS, but also don’t create duplicate topics based on which way you access the page?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 28, 2017, 8:36pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/2 "2017-08-28T20:36:17Z")

</div>

> [@spectrum](#):
>
> Is there a better way I can set this up so the comments show up on our site from HTTPS, but also don’t create duplicate topics based on which way you access the page?

I think that what you want to do is to make both sites https only. On Discourse you can turn on the `force https` site setting.

---

<div class="post-metadata">

### Author: ![spectrum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spectrum/32/142226_2.png) [@spectrum](https://meta.discourse.org/u/spectrum)
#### Post date: [August 28, 2017, 9:17pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/3 "2017-08-28T21:17:07Z")

</div>

I’ll try that out, thank you!  
In my cors origins settings, I have [http://sitename.tld](http://sitename.tld) listed. Do you know if I might run into the duplicate creation issue again if I set this to [https://sitename.tld](https://sitename.tld)?

Either way, I’ll take a look and see if forcing HTTPS will fix this. Thanks!

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [August 28, 2017, 9:19pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/4 "2017-08-28T21:19:20Z")

</div>

> [@spectrum](#):
>
> Do you know if I might run into the duplicate creation issue again if I set this to [https://sitename.tld](https://sitename.tld)?

I don’t know. I do **think** that you want just one of http or https and that the better one is https.

---

<div class="post-metadata">

### Author: ![spectrum](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spectrum/32/142226_2.png) [@spectrum](https://meta.discourse.org/u/spectrum)
#### Post date: [August 29, 2017, 6:41am UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/5 "2017-08-29T06:41:56Z")

</div>

I’ve got it working now – thanks so much!  
I changed only the first link to HTTPS in the Discourse code block. Since this site is transitioning from HTTP to HTTPS, all previously created topics had a discourseEmbedUrl of **http://** sitename.tld/node/blablabla. Changing that to **https** made the topics appear to be recreated. So I ended up changing only the **discourseUrl** to HTTPS, and leaving the discourseEmbedUrl in HTTP to preserve previous topics.

Thank you again! I hope this is helpful for anyone facing a similar transition 🙂

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [September 8, 2019, 2:35pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/6 "2019-09-08T14:35:05Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [April 10, 2023, 2:38pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/7 "2023-04-10T14:38:55Z")

</div>



---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 24, 2023, 1:00pm UTC](https://meta.discourse.org/t/https-support-error-embedding/68944/8 "2023-04-24T13:00:51Z")

</div>

This topic was automatically closed after 13 days. New replies are no longer allowed.
