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

preFetch: urlPath not updated after redirect #16423

Open
021-projects opened this issue Oct 3, 2023 · 0 comments
Open

preFetch: urlPath not updated after redirect #16423

021-projects opened this issue Oct 3, 2023 · 0 comments
Labels
area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues

Comments

@021-projects
Copy link
Contributor

021-projects commented Oct 3, 2023

What happened?

The urlPath value remains the same after the redirect, this can lead to an infinite redirect:

preFetch({ redirect, urlPath }) {
    const isAuthorized = false;

    /* [Vue Router warn]: Detected a possibly infinite redirection in a navigation guard when going from "/" to "/login". Aborting to avoid a Stack Overflow. ...*/
    if (!isAuthorized && urlPath !== "/login") {
      redirect({ path: "/login" });
    }
  },
preFetch({ redirect, currentRoute }) {
  const isAuthorized = false;
  
  // Works correctly
  if (!isAuthorized && currentRoute.path !== "/login") {
    redirect({ path: "/login" });
  }
},

What did you expect to happen?

Correct update of the urlPath property after a redirect

Reproduction URL

https://codesandbox.io/s/trusting-hofstadter-63htmd?file=/src/layouts/MainLayout.vue

How to reproduce?

  1. Go to the provided reproduction link
  2. See the error in console

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Quasar CLI Commands/Configuration (@quasar/cli | @quasar/app-webpack | @quasar/app-vite)

Platforms/Browsers

No response

Quasar info output

No response

Relevant log output

No response

Additional context

No response

@github-actions github-actions bot added area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli bug/1-repro-available A reproduction is available and needs to be confirmed. flavour/quasar-cli-vite kind/bug 🐞 Qv2 🔝 Quasar v2 issues
Projects
None yet
Development

No branches or pull requests

1 participant