-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with and apply global middleware file rather than file based #903
Comments
Two approaches I've found (using Nuxt's middleware guide) are using global middleware (so run the middleware on every page, check if the page matches some criteria, and do something based on that) and setting middleware at build time (use the pages:extend lifecycle hook as part of the nuxt.config.ts file to go through the pages and add middleware based on criteria). The former has the advantage of potentially being more readable since it places all the middleware related files in the middleware directory and seems to be more what you were going for based on the description. The latter has the advantage of not running every time on every page and is more similar to the current system except that all of the middleware additions can be in one file. |
I'd say that performance should trump readability for this, @Robot8lover, so let's go for the second option :) Can we have one separate file that's loaded into the |
Happy to assign if you'd like to work on this! |
Sure, I'd love to work on this. |
And yes, we can just import into the |
Thanks for the confirmation and picking this up, @Robot8lover! |
Right now, the only pages that use middleware are the create pages, which check if the user is signed in. Are there any other pages that should get middleware at this point? |
For right now those are fine, and then we can expand it with individual issues moving forward :) |
Terms
Description
This issue would investigate and implement a file that would serve as the global middleware for the full platform. So rather than having a file based system where we put the middleware in the route that needs it, we'd instead have one file that then defines all the routes that get a specific requirement in order to access them.
Contribution
@UnknownSean8 said he had interest in this one :) Can you write in here and I'll assign? Very happy to support!
The text was updated successfully, but these errors were encountered: