Chat thumbnails bypass s3_cdn_url & use raw S3 bucket URLs

ok for sites with custom emojis added, they will be broken in chat now that the fix is merged.

unlike standard post images (which can be fixed with rake posts:rebake), chat custom emojis are passed to the frontend dynamically via /site.json.

if your database contains S3 URLs that are missing the protocol (e.g., //bucket.endpoint...) or use a virtual-hosted style domain that doesn’t perfectly match your app.yml environment variables, Discourse’s internal CDN replacer silently fails. the raw bucket URL gets passed to the browser, breaking the custom emojis in chat.

how to fix:

to permanently fix this, you need to forcefully remap the raw bucket URLs to your CDN URL in the database, and then clear the site cache so /site.json regenerates.

1. enter your container:

ssh into your server and enter your Discourse container (usually app, or web_only if you have a two-container setup).

cd /var/discourse
./launcher enter app

2. remap the URLs:

run the built-in Discourse remap tool. you should run it twice to catch both the https:// variation and the schemaless // variation that the migration script sometimes leaves behind.

replace the placeholders with your actual raw bucket URL and your actual CDN URL:

# fix the standard https:// URLs
discourse remap "https://<your-bucket>.<your-endpoint>.com" "https://cdn.your-domain.com"

# fix the schemaless // URLs (this is the one that usually breaks custom emojis)
discourse remap "//<your-bucket>.<your-endpoint>.com" "https://cdn.your-domain.com"

3. clear the cache

since /site.json is heavily cached, you must clear the rails cache to force the forum to serve the new URLs:

open rails console:

rails c

run these commands:

Rails.cache.clear
Site.clear_cache
exit

4. refresh

hard-refresh your browser (and disable the theme-component workaround if still using). the custom emojis in chat should now be fixed and load through the CDN properly.

2 Likes