Next.js + NextAuth protect all routes

I want my users to be redirected to NextAuth login page if they try to access any routes in my Next app. I tried adding middleware export { default } from "next-auth/middleware" But this doesn't really work because I get redirected to login page even after I log in
2 Replies
batata
batata2y ago
check if there's a session in the server side on the routes you want (why do you want to redirect on all the routes that doesnt make sense), if there's no session redirect to login
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server