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

Everything to be excluded in redirectOptions except one folder #268

Closed
KosyoK1104 opened this issue Sep 16, 2023 · 7 comments · Fixed by #336
Closed

Everything to be excluded in redirectOptions except one folder #268

KosyoK1104 opened this issue Sep 16, 2023 · 7 comments · Fixed by #336
Labels
question Further information is requested

Comments

@KosyoK1104
Copy link

Hello guys,
I am trying to make sure the authentication check if the user is logged in to be applicable to only one folder and every other to be excluded from it. Should I use some regex if it is possible? Or should I write down every route that should be excluded?

@KosyoK1104 KosyoK1104 added the question Further information is requested label Sep 16, 2023
Copy link
Collaborator

larbish commented Sep 18, 2023

Indeed currently you can only specified routes to exclude from the redirection process. So you need to specify all the "public" routes in the exclude option.

@larbish larbish closed this as completed Sep 18, 2023
@davidparys
Copy link

Indeed currently you can only specified routes to exclude from the redirection process. So you need to specify all the "public" routes in the exclude option.

I'm running onto something similar. Isn't there a hacky way to exclude all but include one single page? I have a very complex structure and I only need one /dashboard page, seems a little bit hectic to have to add all of them.

Copy link
Collaborator

larbish commented Sep 22, 2023

I think the best way to handle this is to disable the redirect option and do the redirection yourself in the concerned page with a simple middleware. If you disable the redirect option, you'll need to configure the callback url for auth as a client rendered route. You can check what this option set under the hood here and here. Hope it helps!

@luizzappa
Copy link

@davidparys , a dirty trick is to reverse engineer this regex here to behave like an include:

const regex = new RegExp(`^${path.replace(/\*/g, '.*')}$`)

If you only need the /dashboard path to be considered, you can use this pattern in nuxt.config:

{
   exclude: ['(?!*\/dashboard*)*']
 }

@jojomatik
Copy link
Contributor

I understand that this is has a low priority, but in my opinion this is a valid feature request. Don't you think @larbish?

I'd argue that this issue should be re-opened. My approach would be to add an optional include property, basically doing the exact opposite of the exclude property.

Copy link
Collaborator

larbish commented Mar 4, 2024

@jojomatik I agree. Feel free to create a PR, I'll be happy to merge it asap.

jojomatik added a commit to jojomatik/nuxt-supabase that referenced this issue Mar 4, 2024
@jojomatik
Copy link
Contributor

Here you go #336

jojomatik added a commit to jojomatik/nuxt-supabase that referenced this issue Mar 4, 2024
jojomatik added a commit to jojomatik/nuxt-supabase that referenced this issue Mar 6, 2024
larbish pushed a commit that referenced this issue Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants