1

I'm using keycloak-react/web and keycloak-js packages in my React project. This is what I have in my keycloak.js

import Keycloak from 'keycloak-js'

const host = window.location.host

const keycloak = new Keycloak({
  url: `http://localhost:8080/auth`,
  realm: 'demo',
  clientId: 'demo',
})

export default keycloak

And this is how I logout the sso-logged-in user

{
  !!keycloak.authenticated && (
    <li>
      <a href='/#' onClick={() => keycloak.logout()}>Logout</a>
    </li>
  )
}

This used to work fine till I switched to keycloak v18.x.x Quarkus. Now, it doesn't even logout the user, let along redirect them to the homepage. What I understand from their documentation, which is stated in this answer, is that they've changed the mechanism to logout. But what I don't understand is how and where do I use this post_logout_redirect_uri

Update: I updated the JavaScript adapter (keycloak-js) to v19.0.1 which at least logs-out the user now but still haven't figured out how to redirect back to the login page

reactn00b
  • 11
  • 2

1 Answers1

1

Update the JavaScript adapter (keycloak-js) to V19.0.1 as mentioned in the question and then make your code like this:

{
  !!keycloak.authenticated && (
    <li>
      <a href='/#' onClick={() => keycloak.logout({ redirectUri: 'http://localhost:3000/' })}>Logout</a>
    </li>
  )
}

Hope this helps!

Goskula Jayachandra
  • 3,931
  • 2
  • 12
  • 22