Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JoaoPedroAS51
Copy link
Collaborator

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' })

Copy link
Member

@CavalcanteLeo CavalcanteLeo left a 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
Copy link
Member

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
Copy link
Member

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,
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants