Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(nuxt): fix router redirection on aliased page - #4982

Merged
pi0 merged 4 commits into
nuxt:mainfrom
huang-julien:fix/router-alias-redirection
May 20, 2022
Merged

fix(nuxt): fix router redirection on aliased page#4982
pi0 merged 4 commits into
nuxt:mainfrom
huang-julien:fix/router-alias-redirection

Conversation

@huang-julien

Copy link
Copy Markdown
Member

resolvenuxt/nuxt#13970

🔗 Linked issue

nuxt/nuxt#13970

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Using the force option on router replace make vue router use the name key in priority to match and retrieve the router location object resulting in a redirection such as the one described in the linked issue. We should just remove the name key from the object passed to router.replace when using force: true

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

- force replace should not have the name key
@netlify

netlifyBot commented May 14, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitb5d3859
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/62823e10bebb560009738ee0

Comment threadpackages/nuxt/src/pages/runtime/router.ts Outdated
@danielroedanielroe added bug Something isn't working pages 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels May 14, 2022
- avoid vue-router matcher using the name to retrieve the non aliased route object with force
Co-authored-by: Daniel Roe <daniel@roe.dev>
@huang-julien

Copy link
Copy Markdown
MemberAuthor

@danielroe i just saw some warning in the CI that did not showed up in local, converting this to draft to confirm that there are not any side-effect

@huang-julien
huang-julien marked this pull request as draft May 14, 2022 19:01
@huang-julien

huang-julien commented May 14, 2022

Copy link
Copy Markdown
MemberAuthor

nvm, it seems that it just disapeared when it re-ran after accepting your suggestion 😄 . However if i remember well, vue-router does not handle very well routes alias with params

@huang-julien
huang-julien marked this pull request as ready for review May 14, 2022 19:09
Comment threadpackages/nuxt/src/pages/runtime/router.ts Outdated
pi0
pi0 approved these changes May 20, 2022

@pi0pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I've noticed same issue on a previous investigation on redirect issues.

Comment threadpackages/nuxt/src/pages/runtime/router.ts Outdated
@pi0
pi0 merged commit 4e53af3 into nuxt:mainMay 20, 2022
@pi0pi0 mentioned this pull request Jun 10, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usagepages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

page alias creates a 301 redirect

3 participants

@huang-julien@pi0@danielroe