#Middleware NextAuth Problem

9 messages · Page 1 of 1 (latest)

fallen sundial
#

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"] };
hazy scaffoldBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

pliant junco
fallen sundial
#

We can try 🙂

fallen sundial
#

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

fallen sundial
#

I had to hash the password before sending beack the user 🙂 xD

chrome garden
#

I still having the same problem

fallen sundial
#

try the code from github and then implement it one by one xD thats what I did

chrome garden
#

send me the link of that code