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

bypassProtection example #80

Open
stvgale opened this issue Feb 28, 2023 · 1 comment
Open

bypassProtection example #80

stvgale opened this issue Feb 28, 2023 · 1 comment

Comments

@stvgale
Copy link

stvgale commented Feb 28, 2023

Having trouble understanding how to use "bypassProtection". An example of this would be helpful.

@charamza
Copy link
Contributor

charamza commented Mar 5, 2023

Hey. It's meant to be able to have some pages (routes) that will not have this password protection applied. To use this, just add property to withPasswordProtect:

withPasswordProtect(MyApp, {
  ...
  bypassProtection: (route) => {
    return route.pathname === '/specific-page/that-doesnt-need-protection' || route.pathname === '/some-other-page'
  }
})

In this example, pages with route /specific-page/that-doesnt-need-protection and /some-other-page will not be protected by password.

route is just object retrieved from useRouter, so you can use all its properties offered from NextJS.

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

2 participants