ERROR An error happened during Keycloak initialization
See original GitHub issueI’m trying to use
try {
await keycloak.init({
config: {
url: 'https://xxxx.com/auth',
realm: 'xxxxx',
clientId: 'account',
credentials: {
secret: 'xxxxxx-980a-4588-a846-xxxxxxx'
}
},
initOptions: {
onLoad: 'login-required',
checkLoginIframe: false
},
bearerExcludedUrls: [
'/assets'
]
});
resolve();
} catch (error) {
reject(error);
}
in the browser see this error:
ERROR An error happened during Keycloak initialization. core.js:1448
defaultErrorLogger core.js:1448
ErrorHandler.prototype.handleError core.js:1509
_callAndReportToErrorHandler/</< core.js:5682:54
ZoneDelegate.prototype.invoke zone.js:388
Zone.prototype.run zone.js:138
NgZone.prototype.runOutsideAngular core.js:4697:47
_callAndReportToErrorHandler/< core.js:5682
ZoneDelegate.prototype.invoke zone.js:388
onInvoke core.js:4749
ZoneDelegate.prototype.invoke zone.js:387
Zone.prototype.run zone.js:138
scheduleResolveOrReject/< zone.js:858
ZoneDelegate.prototype.invokeTask zone.js:421
onInvokeTask core.js:4740
ZoneDelegate.prototype.invokeTask zone.js:420
Zone.prototype.runTask zone.js:188
drainMicroTaskQueue zone.js:595
ZoneTask.invokeTask zone.js:500
invokeTask zone.js:1517
globalZoneAwareCallback zone.js:1543
also:
Pedido de origen cruzado bloqueado: La política de mismo origen no permite leer el recurso remoto en https://xxxxx.com/auth/realms/xxxx/protocol/openid-connect/token. (Razón: encabezado CORS 'Access-Control-Allow-Origin' faltante).
this causes that the web does not load.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
An error happened during Keycloak initialization
Only in Firefox web browser I am getting the below error message: Error: "Uncaught (in promise): An error happened during Keycloak ...
Read more >The account console presents "Failed to initialize keycloak ...
I am new to keycloak and struggling with the same ““failed to initatilize keycloak” issue as others. But the workaround described here (” ......
Read more >keycloak.init's initPromise isn't resolved when init fails - Red Hat
I can confirm this is happening if the keycloak server is down or doesn't exist. There is no error thrown, it seems to...
Read more >KEYCLOAK-16455 Solution to silent fails of JS adapter
Hello all,. Currently, init function in Keycloak JS adapter silently fails when Keycloak URL is unavailable or realm is wrongly configured.
Read more >keycloak-angular - UNPKG
The CDN for keycloak-angular. ... }\n resolve(authenticated);\n })\n .error(kcError => {\n let msg = 'An error happened during Keycloak initialization.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found out what the error is.
The error is CORS ‘Access-Control-Allow-Origin’.
To test it, disable Cross Source Restriction in the Safari browser and it worked correctly.
The configuration of keycloak is standard, do not make any special configuration and the clientId and secret are correct.
analyzing the code, go to line 546 of keycloak.js:
req.status is 0
Any other idea to be able to find the problem.