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

error page not shown after abortNavigation #15053

Closed
vis97c opened this issue Sep 30, 2022 · 7 comments · Fixed by #21047
Closed

error page not shown after abortNavigation #15053

vis97c opened this issue Sep 30, 2022 · 7 comments · Fixed by #21047

Comments

@vis97c
Copy link
Contributor

vis97c commented Sep 30, 2022

Environment

  • Operating System: Windows_NT
  • Node Version: v14.19.1
  • Nuxt Version: 3.0.0-rc.11
  • Nitro Version: 0.5.4
  • Package Manager: yarn@1.22.15
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-i5nygk?file=error.vue

Describe the bug

When throwing an error or aborting navigation from middleware nuxt does not render the error.vue page but instead shows the default nuxt error page. If this is not the intended usage of abortNavigation please provide an alternative.

using showError on a page using middlewares would trigger the same issue.

Additional context

No response

Logs

No response

Copy link
Member

  1. you need to return a value from a middleware, so you return abortNavigation
  2. middleware values are normalised to kebab case - use middleware: 'do-nothing' in your page
  3. your error page isn't loading because of a syntax error (the variable error isn't defined) so it's showing the default error page as a fallback

Here's an updated repro. Hope that helps.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2022
@vis97c
Copy link
Contributor Author

vis97c commented Sep 30, 2022

@danielroe Thanks a lot. I just wanted to point out that the documentation is not clear about requiring you to return:

image

Copy link
Member

we should fix that!

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
@jahidanowar
Copy link

jahidanowar commented Mar 22, 2023

I am having the same issue.

@danielroe The same is not working if we use <NuxtLink> instead of <a>

How would it work if we use <NuxtLink>?

Here's the repro https://stackblitz.com/edit/github-i5nygk-gnbczq?file=pages%2Findex.vue

@danielroe
Copy link
Member

@jahidanowar You are using 3.0.0-rc11. Here's an updated stackblitz: https://stackblitz.com/edit/github-i5nygk-tpvqbg.

Note also this linked issue: #15432.

@xanderbarkhatov
Copy link
Contributor

@jahidanowar You are using 3.0.0-rc11. Here's an updated stackblitz: https://stackblitz.com/edit/github-i5nygk-tpvqbg.

Note also this linked issue: #15432.

Well, it seems like it's working fine. I think the issue could be closed.

@danielroe
Copy link
Member

I think the remaining edge case is that perhaps a fatal error thrown in middleware with abortNavigation should show an error page.

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.

4 participants