Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Nov 13, 2024

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-commenter commented Feb 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.27%. Comparing base (66a6f54) to head (6571e9e).
Report is 171 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2133      +/-   ##
==========================================
+ Coverage   90.77%   91.27%   +0.50%     
==========================================
  Files          24       24              
  Lines        1116     1180      +64     
  Branches      348      379      +31     
==========================================
+ Hits         1013     1077      +64     
- Misses         63       64       +1     
+ Partials       40       39       -1     

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

@posva posva merged commit d992bb2 into main Nov 13, 2024
@posva posva deleted the fix/back-duplication-redirect branch December 5, 2024 09:52
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

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