Preview not working when using object store - wrong markdown-it url

When configuring Object Store, preview for topics/posts are not working.

Discourse is configured with an Object Store
Install is on docker, following the doc.
Discourse version: 2.8.0.beta11

Here are my env variables for S3 configs:

  DISCOURSE_S3_BUCKET: forum-beta-liiib-re

When I check the browser inspector, URL for markdown-it-bundle is pointing to https:

It should not prefix the DISCOURSE_S3_CDN_URL with https: as its already there.

In the console I have the following error:

Loading failed for the <script> with source “”.

I guess my browser is redirecting the https:https://... URL to this one.

I have been trying to find, unsuccessfully, where this URL is set.

If someone can point me to the right direction :slight_smile:

Thanks for your help

1 Like

I think it’s there discourse/application_helper.rb at 70af45055ae24dc7eb1a20678a52ed3ec69421c3 · discourse/discourse · GitHub

That was my guess also, forgot to mention that.

Well I’m not 100% sure as I don’t really have proper dev environment to test everything thoroughly, but it does not seem to come from there.

From what I saw, script_asset_path('markdown-it-bundle') is returning the right URL. And i think its used to build this meta HTML tag which looks fine.

<meta id="data-discourse-setup" data-cdn="" data-base-url="" data-base-uri="" data-environment="production" data-letter-avatar-version="5_c12935382690395be92856801563c2b7" data-markdown-it-url="" data-service-worker-url="service-worker.js" data-default-locale="en" data-asset-version="be5bda1657984e9e27d7d3c27ab24add" data-disable-custom-css="false" data-highlight-js-path="/highlight-js/" data-svg-sprite-path="/svg-sprite/" data-enable-js-error-reporting="true" data-color-scheme-is-dark="false" data-user-color-scheme-id="4" data-user-dark-scheme-id="1" data-s3-cdn="" data-s3-base-url="//">

It seems to be the js that is putting the wrong url with the https: prefix. I could not find where its coming from though.

Its only when I open the editor that I have a <script src="https:"</script> popping up.


I don’t think it’s going to work with S3 CDN URL is a subdomail of S3 endpoint. Can you try using distinct same level subdomains for both?


Ok back on it. Looks like you are right.

So I tried to set DISCOURSE_S3_CDN_URL as a bucket subpath and it is now working.

Do you think it would be reasonable to allow S3 CDN as a subdomain of S3 endpoint ?

In my case, which could be similar to other self-hosted setups, I’m not using an external CDN (nginx on top of minio can be considered as the CDN) so I don’t need to set it on another domain.
I actually setup the subdomain bucket because, I think, its required for discourse to manage uploads

Anyways it solved it and its working for me. Thanks for the help !

1 Like