[Middleware] Guests only routes? #10628
Unanswered
gustaveWPM
asked this question in
Help
Replies: 1 comment 2 replies
-
You can also use the middleware config for v4. export { default } from "next-auth/middleware"
export const config = {
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
The Next Auth documentation says:
https://next-auth.js.org/configuration/nextjs#basic-usage
Okay, perfect.
But if I want to do the opposite, with a page like
/landing-page/dashboard
which should be only visible for guests (i.e: unauthenticated users), and redirecting all logged in users to/dashboard
, what should I do?I would like a middleware approach, to preserve SSG.
Is it supported by Next Auth?
EDIT: Hmmm, maybe it could be easily implemented with Next Auth v5, using
req.auth
I'll try to figure out what I should do with Next Auth v4. :x
Beta Was this translation helpful? Give feedback.
All reactions