Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

137
Vistas
I get an infinite loop when i try to navigata to login page

here is the router.beforeEach function, when the client is not authenticated then he navigate to login page.

router.beforeEach(async (to, from, next) => {
  if ( to.name !== 'signup' || to.name !== 'login' ) {
    if (await checkAuth()) {
     next()
    } else {
      next({name: 'login'})
    } 
  } else {
    next()
  } 
})
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's because of how you write your condition.

if you're going to login page while unauthenticated the flow goes like:

  • 'login' !== 'signup' (true)
  • await checkAuth() (false)
  • execute next({ name: 'login' })

Maybe you meant:

const pagesForAuthOnly = []
const pagesForGuestsOnly = ['login', 'signup']
const authenticated = await checkAuth()

if (pagesForAuthOnly.includes(to.name)) {
  if (authenticated) {
    next()
  } else {
    next({ name: 'login' })
  }
} else if (pagesForGuestsOnly.includes(to.name)) {
  if (authenticated) {
    next({ name: 'home' })
  } else {
    next()
  }
} else {
  next()
}

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda