question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

redirect via navigateTo() not working with nuxt generate

See original GitHub issue

Environment

  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/nuxt-starter-zaokyb?file=pages/index.vue

Describe the bug

having a page redirect to another page via the navigateTo helper does not work with nuxt generate.

e.g.

<script setup lang="ts">
await navigateTo('/target', { replace: true })
</script>

gets rendered as a white page with the text Redirecting to /target.

see attached stackblitz-project for an example.

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
danielroecommented, Jul 26, 2022

Should already be implemented in h3 and you’ll get the benefit in next h3 release 😊

1reaction
pi0commented, Aug 1, 2022

Please use npx nuxi upgrade --force to update lockfile and have latest h3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigate to nuxt error page via client side? - Stack Overflow
In your catch you can redirect user to error page by return this.$nuxt.error({ statusCode: 404, message: 'err message' }).
Read more >
navigateTo · Nuxt Utils
navigateTo redirects to the given path and sets the redirect code to 302 Found by default when the redirection takes place on the...
Read more >
Nuxt Redirects in 4 Steps - Medium
Nuxt Redirects in 4 Steps ... Nuxt uses automatic routing. Nuxt automatically transforms the “pages” folder into basic routes. Therefore, if you create...
Read more >
The router Property - Nuxt
If you want to have a redirect to router.base , you can do so using a Hook, see Redirect to router.base when not...
Read more >
Creating Redirects With Nuxt - Josh Deltener
Using The Nuxt Default Server. If you use Nuxt's default server you have to do a bunch of url parsing and redirecting yourself....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found