redirect action to protected routes(protect with middleware) without authorization will result in URL change #70751
Labels
bug
Issue was opened via the bug report template.
Middleware
Related to Next.js Middleware.
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Performance
Anything with regards to Next.js performance.
Link to the code that reproduces this issue
https://github.com/ehsanrezaeee/next-redirect-bug
To Reproduce
1.Start the application in development mode
2.Click on the deleteCookies button to make sure you are not authenticated.
3.Click on the redirect to protected route using server action Button
4.URL changes but the page doesn't because of the middleware.
Current vs. Expected behavior
Current Behavior:
if you are authenticated using setCookies button (set cookie server action) you can redirect to protectedroute page with either Link or "redirect to protected route using server action" button. However, if you are not authenticated, the Link component will work exaclty as it is but the "redirect to protected route using server action" wont work properly
the "redirect to protected route using server action" will redirect to protectedroute and then middleware activate and redirect back to openroute. However, the URL changes to protectedroute
Expected Behavior:
Provide environment information
Which area(s) are affected? (Select all that apply)
Middleware, Navigation, Performance
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Other (Deployed)
Additional context
I tested the app with dev, build and production environment. The issue exists in all of them
The text was updated successfully, but these errors were encountered: