I’m encountering issues with my middleware function in a Next.js application where redirection based on token validity and URL is not happening as expected. When I have a valid token and navigate to the “/login” URL, it doesn’t redirect me to the dashboard. Additionally, when I delete the token from the cookie, it still shows me the dashboard instead of redirecting me to the login..

Read more