The discussion revolves around the need for relative URLs for uploaded images in Discourse. widepeer initiated the conversation, explaining the issue with full URLs in <img> tags when accessing the site over both HTTPS and a TOR .onion hidden service. They proposed modifying the URL generation to produce relative URLs.
sam acknowledged the issue and suggested that internal changes would be required, potentially involving a conditional check for CDN configuration. widepeer expanded on this idea, suggesting that setting Discourse.cdn_url_no_prefix to an empty string when no CDN is configured could achieve the desired result.
mreach and robbie.morrison expressed their support for relative URLs, sharing their own experiences with domain changes and the need for more flexibility in URL generation. codinghorror countered that a targeted search-and-replace operation can usually resolve issues with domain changes, but others argue that relative URLs would simplify this process.
There is a sympathetic ear from sam, who implied that implementation might be possible in the future.
How can I get Discourse to generate relative URLs for uploaded images?
I have a site that is available over HTTPS and a TOR .onion and I need a way to get images working for both.
How can I configure Discourse so that upload:// URLs are converted to relative URLs in the <img> tag? Where (which source file) does this URL generation take place?
Uploading works correctly both from the HTTPS domain and the TOR hidden service .onion but the actual HTML generated for a post uses a full URL which is a problem.
I’m assuming somewhere there is some code that does something like
This would require some internal changes, I am somewhat sympathetic cause it makes life a bit easier when changing domain names for sites that do not use A CDN.
Would have to be something like, IF no CDN configured then cook a relative url.
And our new host, Communiteq (formerly DiscourseHosting), kindly somehow sedded our database to reflect this change.
Maybe there are technical reasons for the current status? Maybe we can use something like %{THIS}/t/000 in the future? As a developer, absolute paths usually make me nervous. There is also the question of switching from http: to https: which we also undertook (or at least enforced more strictly) as part of the aforementioned migration. This looks like much the same use case as @mreach
As always, many thanks to the discourse team for a wonderful product. R.