Redefine REST API variables

So there are two moving parts at work:

  1. Domain which web server maps to WP installation
  2. Domain WP installation thinks it’s installed on

Under normal circumstances these simply match.

In your case you have two domains mapped to the installation.

WP can only think about one domain at a time. At a time is important part here. You can configure WP to think it’s installed on domain it is being accessed from. So you detect domain of current request from server and configure WP to use it on the fly in config.

This isn’t a common technique really and it comes with fair amount of challenges, since some cases store domain persistently (such as in post content).

However it can be done, it’s just questionable if it’s really worth it and how much tinkering specific site will need to work out kinks.