router icon indicating copy to clipboard operation
router copied to clipboard

beforeEach guard not changing URL after user uses back button

Open dserranog1 opened this issue 2 years ago • 4 comments

Reproduction

https://codesandbox.io/s/epic-dew-cgwffy

Steps to reproduce the bug

  1. Click on login
  2. Click on logout
  3. Click on the browser back button

Expected behavior

After the router intercepts the route, the new URL should be the one I am returning on the beforEach callback.

Actual behavior

The URL is staying as the one it was redirected from.

Additional information

In my actual app, no matter how many times I hit the back button, the URL stays on the route that the router redirected from i.e. the from.fullPath from the beforeEach guard.

I am using version 4.2.1 on my app. It seems it's the same as #916, and the temporal fix also works in this case. The implemented fix (#921) however, doesn't to solve my situation.

dserranog1 avatar May 19 '23 02:05 dserranog1

You are being redirected to the Home page because that’s what you return in the navigation guard

posva avatar May 19 '23 06:05 posva

You are being redirected to the Home page because that’s what you return in the navigation guard

The component being rendered is Home, but the route is /about @posva

Selection_082

dserranog1 avatar May 19 '23 15:05 dserranog1

I'm having the exact same problem described in this issue. I don't understand why it was closed so soon

codePassion-dot avatar May 19 '23 15:05 codePassion-dot

I opened https://github.com/vuejs/router/pull/2133 with a workaround.

posva avatar Feb 06 '24 20:02 posva