Long time Front-end specific Sitecore developer, first time question asker on this particular stack exchange.
Hopefully, the title explains what I'm after somewhat, but we currently have a Sitecore 10.3 instanced in which the front-end repo using Sitecore version 20, Next 12 and React 17 connects to.
We will be migrating to use XM Cloud, but as we transition there is a request to be able to change the SITECORE_API_KEY
env variable so that we can fetch from either the 10.3 service or the XM Cloud service based on a flag provided by another 3rd party package, Launch Darkly.
As far as I'm aware, we will only have access to the decision making flag in the client, which is fine, provided that subsequent fetches went to the alternate endpoint.
Is this even the correct approach for this task? Is this task possible given we have power over the creation of the LayoutService? I am not too sure if its a non standard approach or if theres a better more supported way of achieving what I need here,
Any advice would be appreciated