In a component, how do I find out the base URI of the forum?

If my component is installed on three different forums:

https://forum.someone.com/
https://other.com/forum
https://player.com/

How do I extract the base URI if I’m in a subdirectory like https://forum.someone.com/mytopic/blablaba?

i think perhaps you may be looking for this feature, which is not merged yet

2 Likes

Where do you want to use it?

The Reddit-ish theme, for example, uses discourse/helpers/base-path in the template to create the “the category list” link in the welcome message on the right.

There are also examples where discourse/lib/get-url is used to get the URL in a JavaScript function.

5 Likes