Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

297
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!