How to use env.js
to avoid hardcoding variables in UI app extensions?
#479
Answered
by
tibdex
Harold7665
asked this question in
Q&A
-
Hello,
Does it make sense? If yes, is there any way to do this? Thanks. |
Beta Was this translation helpful? Give feedback.
Answered by
tibdex
Feb 22, 2022
Replies: 1 comment 1 reply
-
Hi, you don't need an const url = `${window.location.origin}/atoti/pyapi/${enpointPath}`; Since you want to 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. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Harold7665
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, you don't need an
env.js
file to do this. You could instead instead make your URL dynamic with something like this:Since you want to
fetch
an endpoint on an ActivePivot server it would be even cleaner to do this in a React component: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
isprotected
.