Middleware NextAuth Problem
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
Hey I have the problem that my middleware always blocks a page even if I am logged in, I wrapped everything in a SessionHandler but it redirects me always to the login page: when I do useSession it works server and clientside. The cookie exist.
my middleware.ts:
my middleware.ts:
// Without a defined matcher, this one line applies next-auth
// to the entire project
export { default } from "next-auth/middleware";
// Applies next-auth only to matching routes - can be regex
// Ref: https://nextjs.org/docs/app/building-your-application/routing/middleware#matcher
export const config = { matcher: ["/legal", "/profile/dashboards", "/dashboard"] };8 Replies
Sun bearOP
We can try 🙂
Sun bearOP
almost solution:
It works again after disabling these lines:
// secret: process.env.SECRET,
// session: {
// strategy: "jwt",
// },
// debug: process.env.NODE_ENV === "development",
maybe because the session key is not hashed as everything else
It works again after disabling these lines:
// secret: process.env.SECRET,
// session: {
// strategy: "jwt",
// },
// debug: process.env.NODE_ENV === "development",
maybe because the session key is not hashed as everything else
Sun bearOP
I had to hash the password before sending beack the user 🙂 xD
I still having the same problem
Sun bearOP
try the code from github and then implement it one by one xD thats what I did
send me the link of that code