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

In CSR app, navigateTo (with external:true) redirection from route middleware triggers page script setup #21314

Closed
nicolaspayot opened this issue Jun 2, 2023 · 2 comments · Fixed by #21521

Comments

@nicolaspayot
Copy link
Contributor

Environment

Nuxi 3.5.2

  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.5.2
  • Nitro Version: 2.4.1
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: ssr
  • Runtime Modules: -
  • Build Modules: -

Reproduction

From https://stackblitz.com/edit/nuxt-starter-77e2za?file=README.md, click on Go to foo link on home page.

You can see Hello, foo! blinking on the browser before it gets redirected. Also, you can see the log onMounted: hello, foo! from the console.

Describe the bug

In a CSR application, when using a route middleware to redirect externally from a Nuxt page to another location (by using navigateTo with external: true), the setup script of the page where we apply the middleware is executed whereas it should not be (I believe?). As well as the lifecycle hooks such as onMounted. It's not the case when redirecting to an internal route.

Additional context

No response

Logs

No response

@nicolaspayot
Copy link
Contributor Author

@danielroe I'm willing to try fixing it!

@danielroe
Copy link
Member

Wonderful!

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

Successfully merging a pull request may close this issue.

3 participants
@nicolaspayot @danielroe and others