Open
Description
Hey @one-aalam,
I am moving way from using composable with @nuxt/supbase to use your model.
I have found I am unable to get the $subpabase in NuxtRouteMiddleware as precisely I could using composable.
export default defineNuxtRouteMiddleware((to, from) => {
const exemptRegRoute = Object.keys(to.query).includes("fromEmail");
const publicRoutes = ["signin", "signup", "forgotpass"];
const privateRoute = !publicRoutes.includes(to.name);
const { $supabase } = useNuxtApp()
const user = $supabase.auth.user()
const user = useSupabaseUser();
if (!user.value && privateRoute && !exemptRegRoute) {
// if not signed in and attemting to visit private route
// reroute to login saving the current destination in the redirect query param
return navigateTo({ name: 'signin', query: { redirect: to.path } });
}
});
Can you suggest a way to achieve this please?
Metadata
Metadata
Assignees
Labels
No labels