[Vuejs]-Nuxt js page with keycloak js authentication middleware reloaded twice when browser window refreshed?nuxtjs router not waiting until promises resolves

3👍

You have to return a new Promise in the middleware, something like this:

export default function({ store, redirect }) {
  if (keycloak.authenticated) return true

  return new Promise((resolve, reject) => {
    keycloak
      .init({
        onLoad: 'login-required',
        checkLoginIframe: true,
        checkLoginIframeInterval: 5
      })
      .success(resolve)
      .error(reject)
  })
}
👤jeam

Leave a comment