-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(module): add option to enable/disable global app middleware #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR.
It might be a good idea since we might use modern CSS/ECMAScript only on a few pages, not all
Can you also provide an example of how to use it on a single page?
definePageMeta({ middleware: 'supportedBrowsers' })
versions: MinimumBrowsersVersion; | ||
redirect?: string; | ||
versions?: MinimumBrowsersVersion; | ||
globalAppMiddleware?: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only global I think is fine
@@ -36,10 +37,19 @@ export default defineNuxtModule<ModuleOptions>({ | |||
}, | |||
}, | |||
}, | |||
|
|||
defaults: { | |||
globalAppMiddleware: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only global I think is fine
@@ -52,6 +52,7 @@ export default defineNuxtConfig({ | |||
"Internet Explorer": null, | |||
"Unknown Browser": 12, | |||
}, | |||
globalAppMiddleware: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only global I think is fine
addRouteMiddleware("supportedBrowsers", supportedBrowsers, global); | ||
const { globalAppMiddleware } = useRuntimeConfig().public.supportedBrowsers | ||
addRouteMiddleware("supportedBrowsers", supportedBrowsers, { | ||
global: globalAppMiddleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only global I think is fine
Add new option
globalAppMiddleware
to enable/disable global app middleware.If global is disabled, it can be enabled per page by adding
definePageMeta({ middleware: 'supportedBrowsers' })