# Making discourseEmbedURL match expected topic requirements

**URL:** https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660
**Category:** Support
**Created:** [2016年八月15日 16:59 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660 "2016-08-15T16:59:57Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Jeff\_Doran](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jeff\_Doran](https://meta.discourse.org/u/Jeff_Doran)
#### Post date: [2016年八月15日 16:59 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/1 "2016-08-15T16:59:57Z")

</div>

I’m trying to utilize discourse in order to provide embedded discussions for an existing web site. The urls of the existing site are not fliexible and I’m trying to work around restrictions on discourse for topic length. For testing I have the following web page at ‘[http://localhost:6543/cases/88](http://localhost:6543/cases/88)’. I’m using a hosted site and have correctly setup the DNS alias to redirect back to the discourse subdomain. I’ve added ‘localhost:6543’ to my discourse site with a default category( which already exists) and am using the following javascript in my html page:

```
 <script type="text/javascript">
     $(function()
     { 
         var DiscourseEmbed = { discourseUrl: 'http://citadel-discussion.lexmachina.com/', 
                           discourseEmbedUrl: 'http://localhost:6543/cases/88' };
         var d = document.createElement('script'); 
         d.type = 'text/javascript'; 
         d.async = true;
         d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
         (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
     });
   </script>

```

The response I get from discourse is

> 404 Not Found

> The resource could not be found.

> /cases/undefinedembed/comments

My assumption here is that the url components are not adequate for a new topic. Since I can’t create any topic with the disourse admin UI that is under a certainly length.

How might I utilize this url to automatically create topics in discourse?  
Must the url string in discourseEmbedUrl match the actual url of the page?

Thanks for your help.

- Jeff

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2016年八月15日 17:19 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/2 "2016-08-15T17:19:25Z")

</div>

I think the problem is your `localhost:6543` is not accessible (it will not accessible if your localhost installation is done in your PC) from the instance where discourse installed. try with live domain name instead of localhost. If it worked correctly Discourse will create new topic automatically when the embedded page loaded. You don’t need to do anything else.

---

<div class="post-metadata">

### Author: ![Jeff\_Doran](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jeff\_Doran](https://meta.discourse.org/u/Jeff_Doran)
#### Post date: [2016年八月15日 21:16 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/3 "2016-08-15T21:16:11Z")

</div>

Thanks Vinoth. I’m testing that idea on a public site, but now I’m running into an error loading the embed.js. I may not have mentioned, but we’re also using google oauth2 to control access to this site. I’ve added [https://meda.discourse.org/auth/google\_oauth2/callback](https://meda.discourse.org/auth/google_oauth2/callback) for the login callback but it looks like we may need to host the embed.js locally unless there are other suggestions.  
Since I’m testing in Safari, I tried changing the discourseUrl to ‘[https://citadel-discussion.lexmachina.com/](https://citadel-discussion.lexmachina.com/)’ so that both would be in the same https domain, but that resulted in an ERR\_CONNECTION\_REFUSED response.

- Jeff

`[blocked] The page at https://citadel-gauth.stage.lexmachina.com/cases/88 was not allowed to run insecure content from http://citadel-discussion.lexmachina.com/javascripts/embed.js.`

BTW, the update javascript looks like this:

```
<script type="text/javascript">
    $(function()
    {

        var DiscourseEmbed = { discourseUrl: 'https://citadel-discussion.lexmachina.com/',
                          discourseEmbedUrl: 'https://citadel-gauth.stage.lexmachina.com/cases/88' };
        var d = document.createElement('script');
        d.type = 'text/javascript';
        d.async = true;
        d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
    });
  </script>

```

---

<div class="post-metadata">

### Author: ![Jeff\_Doran](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jeff\_Doran](https://meta.discourse.org/u/Jeff_Doran)
#### Post date: [2016年八月16日 18:16 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/4 "2016-08-16T18:16:09Z")

</div>

BTW, what exactly is http error code `443: Connection Refused` ?

This is what I get from trying to load embed.js from an https url:

> $curl [https://citadel-discussion.lexmachina.com/javascripts/embed.js](https://citadel-discussion.lexmachina.com/javascripts/embed.js)

Whereas a non-https connection loads embed.js just fine, but then conflicts with the https connection to the html page. I’m not sure how you’d get a successful https connection to a DNS alias since whatever cert you have for ‘[lexmachina.bydiscourse.com](http://lexmachina.bydiscourse.com)’ would not include ‘citadel-discussion.lexmachina’

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2016年八月16日 18:31 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/5 "2016-08-16T18:31:14Z")

</div>

May be you don’t have proper SSL certificates. How can you tell more details about how exactly you using your `lexmachina.bydiscourse.com` and `citadel-discussion.lexmachina` websites?

Are you just pointed citadel-discussion.lexmachina CNAME into [lexmachina.bydiscourse.com](http://lexmachina.bydiscourse.com)? I tried to open this url `lexmachina.bydiscourse.com` on my browser and am unable to reach it.

---

<div class="post-metadata">

### Author: ![Jeff\_Doran](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@Jeff\_Doran](https://meta.discourse.org/u/Jeff_Doran)
#### Post date: [2016年八月16日 18:40 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/6 "2016-08-16T18:40:43Z")

</div>

Okay I was wondering about that, but these are just domains used to access separate discourse forum that we are wanting to use. One is an alias and the other is owned by disourse.

How does someone use an embedded discourse site on a protected page served from https?

I don’t think providing an ssl cert for the alias domain alone would work. I did consider copying and hosting the embed.js file from our server, but it conflicts with our gulp jslint requirements and that quickly proved untenable. I also thought of trying to proxy it though our nginx config might be an option, but I’d much rather see the ability to load embed.js from any https supported site.

Or more directly, can I get an https url for my discourse forum ( ‘[lexmachina.bydiscourse.com](http://lexmachina.bydiscourse.com)’) ?

---

<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: [2019年二月23日 14:29 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/7 "2019-02-23T14:29:28Z")

</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: [2022年三月23日 06:32 UTC](https://meta.discourse.org/t/making-discourseembedurl-match-expected-topic-requirements/48660/8 "2022-03-23T06:32:22Z")

</div>


