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

Nuxt middleware & page setup does not execute in the expected order when refreshing page #564

Open
Andr9651 opened this issue May 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Andr9651
Copy link

🐛 The bug

I was using middleware to fetch user configuration data before navigating to pages, when I realized that the page setup was run before the middleware. Through some trial and error I figured out that removing Nuxt/ionic fixed the issue, but I also found out that adding the Nuxtjs/i18n module worsened the issue.

So I created a project tracking the following:

  • Global middleware
  • Page middleware
  • App setup function
  • Page setup function

And I got these results:

  • (Nuxt alone) works as expected:
    image
  • (Nuxt + Nuxt/ionic) App setup gets run first but everything else in the correct order:
    image
  • (Nuxt + Nuxtjs/i18n) works as expected:
    image
  • (Nuxt + Nuxt/ionic + Nuxtjs/i18n) every page setup is run before middleware
    image

I'm still pretty new to Nuxt & Ionic so I might be completely missing some critical information, but the Nuxt/ionic documentation gives the impression that middleware should just work with no caveats.

🛠️ To reproduce

https://stackblitz.com/edit/hui123

🌈 Expected behaviour

For the execution order to match the basic Nuxt project when refreshing the page, and to also work with the i18n nuxt module

  1. Global middleware
  2. Page middleware
  3. App setup function
  4. Page setup function

ℹ️ Additional context

Reproductions used to get the different results:
Nuxt middleware order (Nuxt only)
Nuxt middleware order (Ionic)
Nuxt middleware order (i18n)
Nuxt middleware order (Ionic + i18n)

It might be related to the ionic router integration, because if I disable it in nuxt.config the execution order goes back to normal.

@Andr9651 Andr9651 added the bug Something isn't working label May 23, 2024
@Andr9651
Copy link
Author

Andr9651 commented Jul 19, 2024

I was hoping the needs reproduction label would disappear after a while, but that doesn't seem to be the case.
That must mean that I'm doing something wrong even though I thought I had provided reproductions. Can anyone point me in the right direction on how to fix my issue, so the needs reproduction label disappears?

@danielroe
Copy link
Collaborator

I'm afraid that is the fault of the bot, not you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants