Favicon.ico and ROOT_URL with sub-directory - how does this work?

Hi,

Our meteor app must support different install scenarios, as it will be set up by customers in their own infrastructure. One of these install scenarios is that the app has no own domain, but runs via a sub-directory URL with reverse proxy. In this scenario we must set ROOT_URL to something like (or otherwise all routes are broken):
export ROOT_URL=https://www.company.com/myapp

This works great except for one thing: favicons!

We put all our icon files into the /public folder.
And we reference them from the main.html file like so:

<head>
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="apple-touch-icon-152x152.png" />
    <link rel="icon" type="image/png" href="favicon-196x196.png" sizes="196x196" />
    <meta name="msapplication-TileImage" content="mstile-144x144.png" />
</head>

<body>
</body>

But with the above ROOT_URL the icons are not served to the webbrowser.

Here is what we tried:

  • export ROOT_URL=https://www.company.com without a trailing sub-directory => OK! Works!
  • putting a “slash” in front of the image resources => no difference
  • putting the URL sub-directory in front of the image resource name. => OK. But this approach is not generic. Es we can not anticipate that string.
  • Further we learned that in the main.html {HEAD} section there is no templating. So we can not use helper methods to calculate the correct path via Assets.absoluteFilePath(assetPath) or Meteor.absoluteUrl([path], [options]) or something.

So here is the question:
How to serve static icons from the {HEAD} section when the ROOT_URL ends with a subdirectory?

I really hope, there is a solution?

Thanks in advance.

Wolfram.

1 Like