Roots Discourse

How to serve theme and plugins assets from correct domain on multi-domain multisite?

I am having a problem with serving static theme assets and plugins assets from the correct domain on our multisite sage website. We have 2 different domains for the multisite. The first domain is maindomain and the second is let’s say otherdomain

So everything works okay when we are on our main multisite with domain maindomain. But when we visit otherdomain, there is a problem with fonts (and other static assets), because they are being served from maindomain, not otherdomain

I did come across a WordPress ticket that could be related to the problem: https://core.trac.wordpress.org/ticket/25650

But I am not entirely sure if it’s not the problem in the Sage theme itself…

Sage theme dist are served from maindomain.com/app/sagetrix/dist/.. instead of otherdomain.com/app/sagetrix/dist/..

Plugins are served from maindomain.com/app/plugins/plugin-name/plugin-assets instead of otherdomain.com/app/plugins/plugin-name/plugin-assets

Images are served from maindomain.com/app/uploads/sites/2 instead of otherdomain.com/app/uploads/sites/2

Here is the config:

Config::define('COOKIE_DOMAIN', '');
Config::define('ADMIN_COOKIE_PATH', '/');
Config::define('COOKIEPATH', '');
Config::define('SITECOOKIEPATH', '/');

Config::define('WP_DEBUG', false);
Config::define('WP_DEBUG_DISPLAY', false);
Config::define('WP_DISABLE_FATAL_ERROR_HANDLER', false);
Config::define('SCRIPT_DEBUG', false);
Config::define('DISALLOW_FILE_MODS', true);

Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', false);
Config::define('DOMAIN_CURRENT_SITE', 'maindomain.com');
Config::define('PATH_CURRENT_SITE', '/');
Config::define('SITE_ID_CURRENT_SITE', 1);
Config::define('BLOG_ID_CURRENT_SITE', 1);

All infos and feedback will be appreciated! Thanks!

I’m interested in this too. Someone can help?

Sage 9 uses this section of its config to determine asset paths: https://github.com/roots/sage/blob/f3e794a09374d2f110742d15b9b975490fcddbee/config/assets.php#L19-L30

If you dig down a bit, the function it calls relies on WP_CONTENT_URL which, as mentioned in the trac ticket linked by @nr007, doesn’t apparently get updated when switch blogs.

You could modify the logic in assets.php to change it to the right URL, or you could filter get_theme_file_uri() (or something else in that call chain). Both of those would likely get you where you need to go.

This topic was automatically closed after 42 days. New replies are no longer allowed.