Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

304
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda