return and next behave differently in the beforeEach guard. #2335
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
0 replies
-
When I replace next with return to.fullPath, it proceeds to the else block and does not trigger a second pushWithRedirect. |
Beta Was this translation helpful? Give feedback.
0 replies
-
sorry The return statement is called at an inappropriate point. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reproduction
production
Steps to reproduce the bug
Expected behavior
I'm encountering an unexpected behavior with Vue Router's beforeEach guard. Despite following the documented approach of returning to.fullPath to initiate a redirect, the navigation isn't occurring as anticipated. I've discovered that employing next within the guard is the sole method to successfully trigger a redirect.
Actual behavior
I'm encountering an inconsistency in Vue Router's beforeEach guard behavior. While utilizing the next method results in a successful second route match, returning to.fullPath doesn't trigger a subsequent guard execution. This discrepancy leads to an unrendered page.Additional information
I'm encountering an issue with Vue Router's beforeEach guard. I'm expecting return to.fullPath to initiate a redirect, but the guard isn't being re-evaluated and the route doesn't match. Switching to next(to) resolves the issue. Could you please explain the underlying mechanism and why this behavior occurs?
vue-router version: 4.0.16
vue version: 3.2.45
Beta Was this translation helpful? Give feedback.
All reactions