Skip to content

How to use env.js to avoid hardcoding variables in UI app extensions? #479

Answered by tibdex
Harold7665 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, you don't need an env.js file to do this. You could instead instead make your URL dynamic with something like this:

const url = `${window.location.origin}/atoti/pyapi/${enpointPath}`;

Since you want to fetch an endpoint on an ActivePivot server it would be even cleaner to do this in a React component:

const defaultServerKey = "default";
const client = useActivePivotClient(defaultServerKey);
const url = `${client.url}/atoti/pyapi/${enpointPath}`;

since that would decouple your URL definition from the fact that the UI and your endpoint are currently served from the same origin.
However, it's not possible today because Client.url is protected.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Harold7665
Comment options

Answer selected by Harold7665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants