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:
// 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"] };