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

298
Vistas
nuxt.js: how to do the same validation for pages in one subdirectory

I started to migrate my pet project from pure VueJS to Nuxt, because of the tone of its useful features. My frontend part has a number of pages that are only accessible for admin users, but it becomes very tedious to write the same validate methods for them.

Things start to be better when I write admin validation in the middleware component and moved all admin pages in the one subdirectory. But in that case, you also need to manually write this middleware in all admin pages, which leads to bugs, when you just forget to do so.

So is it possible to somehow add middleware for all admin pages at once?

I see only one solution for it: write a module that before creating Vue instance, looking for its path in the project, and injecting middleware if the path starts with @/pages/admin. But I'm not proficient in Nuxt nor Vue, so I can't understand how to do it properly.

I believe that it is quite common problem for big websites and don't understand why I can't find any solution to this.

So how to add the same validation for pages laying in the one subdirectory?

about 4 years ago · Juan Pablo Isaza
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