The script resource is behind a redirect, which is disallowed

(Jernej) #1

Hello. I am currently having an issue with embedding Discourse on WordPress website.

I have set the following:

Allowed Host:

But I get the following error response in Chrome Console:

The script resource is behind a redirect, which is disallowed.
Failed to load resource: net::ERR_UNSAFE_REDIRECT service-workers.js

In Firefox I get this text displayed:


The software powering this discussion forum encountered an unexpected problem. We apologize for the inconvenience.

Detailed information about the error was logged, and an automatic notification generated. We’ll take a look at it.

The Iframe is loaded but it only displays Loading Comments. I am doing the loading of the scripts via AJAX response. Perhaps that might be the issue?

Any help would be greatly appreciated.

Embedding Discourse Comments via Javascript
(Rafael dos Santos Silva) #2

I bet it is.

Just load it in the standard way, the script tag.

(Jernej) #3
<div id='discourse-comments'></div>";
    		<script type='text/javascript'>
    			  DiscourseEmbed = { discourseUrl: '',
    								 discourseEmbedUrl: '' };

    			  (function() {
    				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);

I have added the code above in the PHP file (that is not dynamically generated by AJAX), but I get the following error in Chrome:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

(Quim Gil) #4

Just in case: you are taking the embedding route because you don’t have access to the installation of plugins in your WordPress, right?

(Rafael dos Santos Silva) #5

Hmm, To Serve Man, with Software is loading just fine for me.

Can you update Discourse to latest? Can you share the URL where the comments are embedded ?


we’re actually trying to load this a wordpress site (currently behind a temp maintenance page) and this forum. everything is updated to the latest.

(Rafael dos Santos Silva) #7

Why not use the official Wordpress plugin?


we’re not trying to have every post create a new topic. we’re just trying to embed one particular topic or category into a page.

(Joshua Rosenfeld) #9

I could be wrong (please correct me if I am @Simon_Cossar) - but with the official plugin you can choose selectively whether to create a Discourse topic or not.


Right, but we already have an existing page and want to insert a specific category or existing thread into it, if that makes sense. we’re not going to have wordpress create new posts/pages and have it create a new thread.


i’ll dig in a bit deeper on the plugin and see if we can configure it to do what we want. :slight_smile:

(Simon Cossar) #12

The WordPress plugin has an option to link WordPress posts to Discourse topics without publishing the post from WordPress to Discourse. That might do what you’re looking for.

(Quim Gil) #13

Since a couple of weeks, the plugin allows you to connect a WP page with an existing Discourse topic. However, as far as I am aware you cannot link to a category, or to anything other than a topic.

(Jernej) #14

Regarding the WP Discourse plugin, I have a question. Since we are loading a lot of the post content dynamically with AJAX (normally that would be loaded via single.php/page.php file), we would need some sort of shortcode/function that would display the corresponding Discourse topic for the given page as provided by the custom field in the wp-admin.

Is there any documentation of the WP-Discourse plugin that would explain how this kind of implementation could be achieved with shortcodes/functions for displaying the Discourse topics?

So for example a simple template tag like: get_discourse_topic($post_id); or anything in that manner. Also are there any additional JavaScript triggers needed to be aware of when loading Discourse topics with AJAX?