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

Troubles with nested relative redirects #2014

Closed
arthabus opened this issue Oct 12, 2023 · 2 comments
Closed

Troubles with nested relative redirects #2014

arthabus opened this issue Oct 12, 2023 · 2 comments

Comments

@arthabus
Copy link

arthabus commented Oct 12, 2023

Reproduction

https://jsfiddle.net/y1Luxt7v/

Steps to reproduce the bug

  1. Open reproduction link above
  2. a. Click "start"
  3. b. Click "start" one more time

Expected behavior

Url shows "url: /app/dashboard/list/sublist"

Actual behavior

2a. url shows "url: /_display/dashboard/list"
2b. url shows "url: /_display/dashboard/dashboard/list"

Additional information

In VueRouter v3 it was possible to use a relative redirect (no leading slash in the redirect path) and if redirected to a child path, the path was concatenating like "parentPath/childPath".

Seems like this is no longer how it works in VueRouter v4 and instead it doesn't seem to respect the parentPath and only uses childPath when determining the final redirect location. This brings tons of troubles in our application as we were heavily relying on that logic before, so I hope for advice.

Copy link
Member

posva commented Oct 12, 2023

This change was indeed intended: relatives paths are always resolved based on the current location to avoid inconsistencies to how Relative URLs work. In your case, the first redirect is absolute, it works, the second one is relative, it resolves to a route you don't have and then it stops. I recommend you to do one of these:

  • use absolute paths in redirects
  • use named routes for a deterministic route location
  • remove the links in your application that are using any of the routes that have a redirect

This has been overlooked in the migration guide, if you can, it would be a great contribution!

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Oct 12, 2023
@arthabus
Copy link
Author

arthabus commented Oct 12, 2023

got you, @posva. At least now I know for sure what the issue is. Named redirects seem to be the only option for now. Thanks for your help!

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

No branches or pull requests

2 participants