Hi, do you support running GD.UI in a non-root dir...
# gooddata-ui
d
Hi, do you support running GD.UI in a non-root directory? I setup "homepage" in package.json to point to the correct directory, so the scripts and everything load fine, but GD keeps trying to make
/api/profile
requests to the root directory instead of the folder it's in.
j
Yes, a GD.UI application boostrapped using @gooddata/create-gooddata-react-app can run in a non-root directory.
But you have to build it using
PUBLIC_URL=/folder/another-folder yarn build
.
Are you talking about GD.UI application bootstrapped with @gooddata/create-gooddata-react-app? Are you running it on your localhost, or are you trying to deploy it? Are you connecting it to a hosted platoform SaaS (codename Bear), or to a self-hosted GoodData.CN instance (codename Tiger)?
d
Thanks, I'll try the env argument. I'm using the React bootstrap app and connecting it to a self-hosted CN instance. Currently I'm exploring ways to integrate GD.UI into our existing (non-React) web application. Although I'm running everything locally at the moment, our development environment largely mimics our deployment environments, so the only thing that should change with deployment is the domain.
I think I misunderstood the way the React app works; I expected to be able to setup some predefined charts in the React app, build the React app, and then be able to place the built files onto a folder on a web server, where it would communicate with GD.CN and display the charts. I don't know if that's possible, or if you have to use the approach from https://sdk.gooddata.com/gooddata-ui/docs/4.1.1/ht_use_react_components_with_vanilla_js.html if you want to integrate GD into a non-React web application. I wanted to avoid that specifically because working with GD.UI in React is much nicer than the vanilla JS examples in the linked documentation.
j
One more hint to avoid GD keep trying to make
api/profile
requests to the root directory: When instantiating the backend, make sure to pass the
hostname
param, like this:
Copy code
const backend = tigerFactory({
  hostname: '<https://interactive-examples-proxy.herokuapp.com/>',
}).withAuthentication(...);
Also please check
build-with-explicit-hostname
in package.json to see the effect of
REACT_APP_SET_HOSTNAME
env variable. I believe these are what you are looking for.
As for your understanding the way the React app works, I think you get it. I see that you want to pre-build an individual React app separately, and then "plug it in" your non-React app, correct? Well, this might be tricky to set up, but it shouldn't be impossible. I really think that the
{ hostname: '<https://my-domain.com>' }
config when instantiating the tigerFactory should be helpful, as well as
REACT_APP_SET_HOSTNAME
to make it apply when creating a production build. Please let me know if it helps!
d
I did just notice
REACT_APP_SET_HOSTNAME
in the code documentation, I believe that was the missing piece.
j
Sorry I didn't mention this earlier! Hope it works! 🤞
d
So I did actually have it on because I tried
build-with-explicit-hostname
earlier, but it looks like I needed both that and the
hostname
parameter in
tigerFactory
. It's sending requests for the correct host now, thanks!
👏 1
j
Amazing! Good job! Díky Dane!
👏 1