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

How can I disable middleware for certain pages? #45

Open
VegasChickiChicki opened this issue Aug 17, 2023 · 0 comments
Open

How can I disable middleware for certain pages? #45

VegasChickiChicki opened this issue Aug 17, 2023 · 0 comments

Comments

@VegasChickiChicki
Copy link

Perhaps there is no such functionality now, if so, then it is necessary. I think that in many projects there are pages with protected paths, for viewing which authorization is necessary.

import { storeToRefs } from 'pinia';
import { useAuthStore } from '@/store/auth';



export default defineNuxtRouteMiddleware((to) => {
	const authStore = useAuthStore();
	const { authState } = storeToRefs(authStore);

	if (!authState.value && to.path !== '/login') {
		return navigateTo('/login');
	}
});

I have such middleware, how will storybook behave if I create page histories with such middleware.

I also think it would be great to add a description of this behavior to the documentation.

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

No branches or pull requests

1 participant