We have a react app running on multiple domain names, but I am unsure of how to get the current domain name in react.
E.g. The app runs the same code on www.example-one.com and www.example-two.com but using window.location or document.location.href etc just returns localhost as the app is served via a reverse proxy in Apache.
How do I get it to return www.example-one.com or www.example-two.com?
EDIT:
After some more testing the issue was because I was using location.href before the component had mounted. Moving the code to componentDidMount allowed me to access the domain name. Thanks for your help