supabase
supabase copied to clipboard
The ability to define pages requiring authentication
Each time a user is trying to access a page that needs authentication, he will automatically be redirected to the configured log in page. If you want to allow access to "public" page, you just need to add them in the exclude redirect option.
I believe that it would be highly beneficial to have an option that serves as the opposite of the 'exclude' param. In my specific use case, I have numerous public pages, including multiple versions of landing pages that are directly accessible from the root (/landing-page-name
). Consequently, excluding them using wildcards seems to be impossible. On the other hand, there is only one URL (/dashboard/**
) that requires authentication.
I'm having the same issue. having an include option would be great!
@lukaszflorczak I agree, this is a common issue I've run into multiple times.
Having a useAuth
boolean in the config would also be nice for websites that don't require auth.
However, I have found that exclude: ['/*']
also does the trick.
i agree
+1
I totally agree. I want everything under /app/ to require auth and nothing else so an include option is a must.
Up for this feature!
For now a workaround is to reverse engineer this regex here to behave like an include:
https://github.com/nuxt-modules/supabase/blob/0294a01cf71f10dad49679a4443eb224c4ec92bf/src/runtime/plugins/auth-redirect.ts#L15
For instance, If you only need the /dashboard
path to be considered, use this pattern in nuxt.config
:
{
exclude: ['(?!*\/dashboard*)*']
}
I just saw that it's implemented. now you can use include:
redirectOptions: {
login: '/login',
callback: '/confirm',
include: ['/dashboard(/*)?'],
}
"
include
: Routes to include in the redirect. ['/dashboard(/*)?']
will enable the redirect only for the dashboard page and all sub-pages.
"
https://supabase.nuxtjs.org/get-started#redirectoptions