How do you ensure the versions are aligned? #10239
Unanswered
jim-alexander
asked this question in
Q&A
Replies: 1 comment
-
|
If anyone else stumbles across this we ended up loading the external keycloak js adapter inside of a promise so we could ensure things happened in the order they are meant to: const loadScript = () =>
new Promise<void>((resolve, reject) => {
const url = window._env_.REACT_APP_KEYCLOAK_URL + '/js/keycloak.js'
const keycloakScript = document.createElement('script')
keycloakScript.src = url
keycloakScript.onload = () => resolve()
keycloakScript.onerror = () => reject(new Error(`Could not load keycloak script from: ${url}`))
document.head.appendChild(keycloakScript)
})And then consequently ... await loadScript()
const keycloakInstance = window.Keycloak({
url: window._env_.REACT_APP_KEYCLOAK_URL,
realm: 'some-realm',
clientId: 'some-client',
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
It is stated that:
We have found timing issues when doing this as Keycloak will be undefined if it hasn't finished loading the script tag. So we want to bundle it with our app instead with
npm install keycloak-js@relevant-versionto have confidence its always accessible.I can version match the npm install no problem, but is everyone installing keycloak-js instead of loading it from the IDP not following best practice? OR is there a way that keycloak-js knows which version to use after specifying the url in the config?
Beta Was this translation helpful? Give feedback.
All reactions