keycloak-angular icon indicating copy to clipboard operation
keycloak-angular copied to clipboard

Web Crypto API is not available when accessing Angular app via IP instead of localhost

Open XardasLord opened this issue 9 months ago • 1 comments

I use the following versions: "keycloak-angular": "^16.1.0", "keycloak-js": "^26.1.2",

My keycloak configuration is the following:

export function initKeycloak(keycloak: KeycloakService) {
  return () =>
    keycloak.init({
      config: {
        url: 'http://192.168.0.185:9080',
        realm: 'az-integrator',
        clientId: 'az-integrator-client',
      },
      initOptions: {
        onLoad: 'check-sso',
        checkLoginIframe: false,
        enableLogging: true,
      },
      enableBearerInterceptor: true,
      bearerPrefix: 'Bearer',
    });
}

If I run the project locally (localhost:8000) everything works fine. If I access the angular app from my PC IP addres, so 192.168.0.185:8000 I'm getting the following error:

Web Crypto API is not available.
    at createUUID (keycloak-angular.js?v=842b056e:854:13)
    at Keycloak.<anonymous> (keycloak-angular.js?v=842b056e:339:19)
    at Generator.next (<anonymous>)
    at chunk-WDMUDEB6.js?v=842b056e:49:61
    at new ZoneAwarePromise (polyfills.js:2159:23)
    at __async (chunk-WDMUDEB6.js?v=842b056e:33:10)
    at Keycloak.kc.createLoginUrl (keycloak-angular.js?v=842b056e:338:12)
    at Object.<anonymous> (keycloak-angular.js?v=842b056e:1086:45)
    at Generator.next (<anonymous>)
    at chunk-WDMUDEB6.js?v=842b056e:49:61

I cannot find any issue related to this

XardasLord avatar Feb 20 '25 14:02 XardasLord

That is most probably due a change in 26.0.6 of keycloak-js

Please see A secure context is now required

schreibse avatar Apr 10 '25 14:04 schreibse