N
Nuxt2y ago
roga

Nuxt & Supabase Auth

I've set up working authentication in my Nuxt 3 app. I have an authGuard middleware that I've set up which is super basic:
export default defineNuxtRouteMiddleware((to, _from) => {
const user = useSupabaseUser();
if (!user.value) return navigateTo('/login');
});
export default defineNuxtRouteMiddleware((to, _from) => {
const user = useSupabaseUser();
if (!user.value) return navigateTo('/login');
});
The thing is, I'm redirecting from '/login' to '/dashboard' but if I auth guard the dashboard, it immediately sends the user back to '/login' because the very first instant when the script runs, there is still no user registered. How can I make sure that I wait until the Supabase does it's thing, registers that there is a suer, before checking for a user and redirecting if none is found?
5 Replies
roga
rogaOP2y ago
I'm getting the distinct impression this is a Supabase problem. It has other issues like #NuxtLinks just stop working as well. I'm guessing it's just not "there yet"...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
SunTzu
SunTzu2y ago
It doesn't seem that auth login works on Static hosting. The login works, however the session does not stick or something..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
JavascriptMick
I don't have your exact problem but I have my supabase auth and guards working pretty good here https://github.com/JavascriptMick/nuxt3-boilerplate hth
GitHub
GitHub - JavascriptMick/nuxt3-boilerplate: Simple boilerplate for S...
Simple boilerplate for SAAS. Nuxt3, Supabase, OAuth, Prisma, TRPC, Pinia, Stripe - GitHub - JavascriptMick/nuxt3-boilerplate: Simple boilerplate for SAAS. Nuxt3, Supabase, OAuth, Prisma, TRPC, Pi...
Want results from more Discord servers?
Add your server