Redirect Problem
hello again, I am struggling with another interesting problem.
I am using Next 15.3.0 and my middleware.ts file is as follows
If the user quickly changes pages in a row or performs a repetitive action, they are suddenly redirected to the homepage, but no buttons or functions work after the redirection
@Ping
I will ask for your support in this matter 🙏
4 Replies
I fixed it with getSessionCookie, I'll leave it in case anyone else is experiencing this error
but now if the user is deleted, it is considered logged in because the cookie remains. Is there a clear solution to this problem?
@Ping @bekacru
@bekacru can you help me ?
The middleware is a meant to be a shallow check. You still need to fetch session on each page and validate if the user has a session or not. So even if the user has a cookie but they are deleted or their session is revoked, the session check on the page/route should be the protection
what's the point of the middleware if i had to check it again on the actual page?
It's faster to check via middleware, than having a server run SSR just to redirect.