Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): allow duplicated navigation on back + redirect #2133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

posva
Copy link
Member

@posva posva commented Feb 6, 2024

Fix #1850

I need to test this more as it could have other consequences. For the moment a workaround is to avoid the navigation duplication:

router.beforeEach((to, from) => {
  if (!localStorage.getItem("JWT") && to.name !== "Home") {
    console.log("intercepting, no token, URL should be: ", from.fullPath);
	if (from.name === 'Home') return false // avoid duplicated navigation
    return { name: "Home" };
  }
});

Copy link

netlify bot commented Feb 6, 2024

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 6571e9e
🔍 Latest deploy log https://app.netlify.com/sites/vue-router/deploys/65c29b5f9ecbe20008f3c550

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2df32af) 90.85% compared to head (6571e9e) 91.27%.
Report is 9 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2133      +/-   ##
==========================================
+ Coverage   90.85%   91.27%   +0.41%     
==========================================
  Files          24       24              
  Lines        1115     1180      +65     
  Branches      347      379      +32     
==========================================
+ Hits         1013     1077      +64     
- Misses         63       64       +1     
  Partials       39       39              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

beforeEach guard not changing URL after user uses back button
2 participants