Proper way to handle WP_HOME within a multisite

The WP_HOME .env property is confusing to me. By default it has these values:

WP_HOME='http://example.com'
WP_SITEURL="${WP_HOME}/wp"

But what if you have a multisite with sites using the exact same theme (not a child theme)? So:

Site A: example.com
Site B: example-b.com

Site A is fine, Site B is mostly fine but is trying to fetch plugin assets and such from Site A which isn’t nice and results in CORS errors.

This can be fixed by adding changing the WP_HOME in application.php with:

define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);

Perhaps this is wrong and there is probably a reason for doing it like this. But can someone tell me what the proper practice is?

Still looking for help on this, any experience with your own projects would be much appreciated!

Unfortunately using the above solution breaks the WP CLI with:
PHP Warning: Undefined array key "HTTP_HOST"

e.g. when doing wp cap list 'administrator'