In a discussion titled “Invalid URL for markdown-it-bundle” under the Installation category, JustinBack reports that after enabling S3_CDN_URL in their Discourse setup, all assets load correctly except markdown-it-bundle, which gets incorrectly prefixed with the site’s base URL (e.g., https://tosdr.community/https://...). Despite verifying uploads and asset paths in the database, the issue persists. crcoli7307 suggests reviewing the official S3 setup guide, while JammyDodger shares a related topic with a similar problem. JustinBack confirms following the guide and tries changing the CDN URL to https://s3.jrbit.de/tosdr-community, but this breaks stylesheet loading—possibly due to bucket name/domain similarity (tosdr-community vs tosdr.community). After migrating to a new bucket with no improvement, JustinBack investigates via Rails console and confirms script_asset_path generates the correct URL, pointing to a known bug referenced in the S3 setup thread. As a temporary workaround, they hardcode a redirect in Nginx to serve the correct asset URL directly from S3, acknowledging it will break if the asset hash changes. The issue appears to be a Discourse-specific bug with S3 CDN asset resolution for markdown-it-bundle.
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:
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!)
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
EDIT 2:
I “fixed” it by using the most dirtiest workaround available. Hardcoding the Asset in the nginx config and redirecting it