# Invalid URL for markdown-it-bundle

**URL:** https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463
**Category:** Self-hosting
**Tags:** cdn, s3
**Created:** [December 10, 2022, 8:49am UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463 "2022-12-10T08:49:55Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [December 10, 2022, 8:49am UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/1 "2022-12-10T08:49:55Z")

</div>

After doing an update today and enabling the S3\_CDN\_URL Option in the envs, everything but markdown-it-bundle loads.

```plaintext
https://tosdr.community/https://tosdr-community.s3.jrbit.de/assets/markdown-it-bundle-5a633717415fd164893a925e4cac1406ecab8179d15637506b08a147ab543433.br.js

```

While the assets on the server exist and have been uploaded, discourse still prefixes with the base url.  
All other assets work just fine.

I have checked the uploads table, and all urls have the proper format.

Is there any other table I can look into or just a plain fix for this issue?

Is there any DbHelper like `remap` but for searching a string in the whole database?

---

<div class="post-metadata">

### Author: ![crcoli7307](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crcoli7307/32/267901_2.png) [@crcoli7307](https://meta.discourse.org/u/crcoli7307)
#### Post date: [December 12, 2022, 2:09am UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/6 "2022-12-12T02:09:27Z")

</div>

Did you follow a guide for setting up Discourse with S3? It seems like there is a lot of sophisticated straps you have to follow in order to set it up, according to this topic:

> [@Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916):
>
> information_source This topic covers how to configure some common S3 compatible Object Storage providers (S3 clones). See [Set up file and image uploads to S3](https://meta.discourse.org/t/setting-up-file-and-image-uploads-to-s3/7229) for more details about Amazon AWS S3 configuration, which is officially supported and used internally by Discourse for our hosting services. Provider Service Name Works with Discourse? [Amazon AWS](#aws-s3-2) S3 Yes [Digital Ocean](#digital-ocean-spaces-3) Spaces Yes [Linode](#linode-object-storage-4) Object Storage Yes [Google Cloud](#google-cloud-platform-storage-5) Storage Yes [Scaleway](#scaleway-object-storage-6) Object Storage Yes [Vultr](#vultr-object-storage-7) Obj…

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [December 12, 2022, 3:18am UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/7 "2022-12-12T03:18:01Z")

</div>

I’m afraid this isn’t my forte, but I found this topic with a similar issue, if that might be of some help?

> [@Preview not working when using object store - wrong markdown-it url](https://meta.discourse.org/t/preview-not-working-when-using-object-store-wrong-markdown-it-url/215549):
>
> 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\_CDN\_URL: https://discourse.liiib.re DISCOURSE\_USE\_S3: true DISCOURSE\_S3\_REGION: default DISCOURSE\_S3\_ENDPOINT: https://hot-objects.liiib.re DISCOURSE\_S3\_ACCESS\_KEY\_ID: ACCESS\_KEY\_ID DISCOURSE\_S3\_SECRET\_ACCESS\_KEY: SUPER\_SECRET\_KEY DISCOU…

---

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [December 12, 2022, 11:02pm UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/8 "2022-12-12T23:02:16Z")

</div>

@crcoli7307 Yes that was exactly the topic I followed through 🙂

* * *

@JammyDodger

Thank you for the topic!

So I changed the S3\_CDN\_URL to:

```plaintext
DISCOURSE_S3_CDN_URL: https://s3.jrbit.de/tosdr-community

```

But sadly this broke everything, in terms of where the stylesheet loads from.

Could this be the bucket name as its almost equal to the domain?

Bucket name: tosdr-community  
Domain: tosdr.community

 ![Screenshot 2022-12-13 000206](https://global.discourse-cdn.com/meta/original/4X/0/1/d/01da29d3b209d1b1a3c6140953afd969d23d2844.png)

See how the stylesheets are constructed.

---

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [December 13, 2022, 12:39am UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/9 "2022-12-13T00:39:25Z")

</div>

Just migrated to a new bucket: Its not the name of the bucket, same issue happening

---

<div class="post-metadata">

### Author: ![JustinBack](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justinback/32/133266_2.png) [@JustinBack](https://meta.discourse.org/u/JustinBack)
#### Post date: [December 13, 2022, 8:34pm UTC](https://meta.discourse.org/t/invalid-url-for-markdown-it-bundle/248463/10 "2022-12-13T20:34:02Z")

</div>

UPDATE: I just checked the way markdown-it-bundle is embedded and executed the script\_asset\_path through the rail console (with slight modifications due to the missing request.env variable!)

![image](https://global.discourse-cdn.com/meta/optimized/4X/3/7/f/37fc6dea30046aee5f8a759c53edb5843f763bb9_2_690x40.png)

According to the script\_asset\_path, the asset url is correctly generated. Still not sure why this is happening.

EDIT:

It seems to be a known bug

> [@Configure an S3 compatible object storage provider for uploads](https://meta.discourse.org/t/configure-an-s3-compatible-object-storage-provider-for-uploads/148916/258):
>
> I’m also in this situation with an object store configured (minio) but no CDN. Is it a use case that could be supported ? From what I’m seeing so far in my tests there is only the markdown-it-bundle js file that is having issues as its pointing to the wrong URL - DISCOURSE\_HOSTNAME/DISCOURSE\_S3\_CDN\_URL/assets/markdown-it-bundle-HASH.br.js It actually looks lit a bug for this one, if I set DISCOURSE\_CDN\_URL variable, it still points to the wrong URL in this form DISCOURSE\_HOSTNAME/DISCOURSE\_CD…

EDIT 2:

I “fixed” it by using the most dirtiest workaround available. Hardcoding the Asset in the nginx config and redirecting it

```nginx
location ~ markdown-it-bundle-dcd9743077867b3a68d7b723130cb2711dc4c843b018d7bc609f868289402fef.(.*).js {
return 302 https://tosdr-forum.s3.jrbit.de/assets/markdown-it-bundle-dcd9743077867b3a68d7b723130cb2711dc4c843b018d7bc609f868289402fef.$1.js;
}

```

Did the trick, unless the asset is updated 🙂
