Full URL in assets erb file --> multisite issues

Reading the current implementation of UrlHelper.absolute:

https://github.com/discourse/discourse/blob/master/lib/url_helper.rb#L28-L31

Looks like it will compose the URL by concatenating Discourse.base_url_no_prefix plus the parameter when CDN is nil, which is your case.

So the problem is that Discourse.base_url_no_prefix is returning always the first host in the multisite environment?

image

Looking into the code :eyes:

https://github.com/discourse/discourse/blob/master/lib/discourse.rb#L286-L293

the name of the variable here current_hostname @ 288 strongly suggests something multisite aware :thinking:

and by

https://github.com/discourse/discourse/blob/master/lib/discourse.rb#L273-L276

it looks like it is. Dead end so far…

Looking elsewhere, this route gained some special sauce because browsers love to hammer it HARD, and we aren’t allowed to put it on a CDN and make it someone else problem. While doing this, we had a bug involving a multisite leak, which was fixed by @sam one year ago:

https://github.com/discourse/discourse/commit/abf0b1c5bd8afdfdc53a035eccac3485de659bfa

Is there a possibility that the way you are serving this multisite cluster is caching this route in a leaky way, like we were in early 2018?

2 Likes