Next.js Discord

Discord Forum

protected routes with next auth

Unanswered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
i tried from the next auth [docs](https://next-auth.js.org/tutorials/securing-pages-and-api-routes#nextjs-middleware) to do this
export { default } from "next-auth/middleware"

export const config = {
  matcher: ["/dashboard/:path*"],
}
but it redirects me to sign in page even when im logged in

6 Replies

American ChinchillaOP
any1?
New Guinea Singing Dog
Because you're not checking if you are actually logged in
You're automatically redirecting
Don't you need to get the session?
American ChinchillaOP
It said that is enough to get it working with next auth
@New Guinea Singing Dog Don't you need to get the session?
American ChinchillaOP
using getServerSession ?