NuxtN
Nuxt12mo ago
9 replies
anton_toshik

navigateTo doesn't work on client side while middleware is still running

I wanted to clarify what to do in this situation

1. page with button is rendered
2. button is clicked

button on click: navigateTo('/whatever')

now due to "middleware still running" in this code block, the navigateTo doesn't actually navigate: https://github.com/nuxt/nuxt/blob/9b689ea8261bc65363a9882d8e4051575e0c78d9/packages/nuxt/src/app/composables/router.ts#L154

if I use router.push('/whatever') everything works

I couldn't make a reproduction because it requires a testing framework to click the button very quickly.

my expectation is that if the page is being rendered, the middleware should already be finished by then. Is it more likely the problem is on the framework side or my incorrect usage of the middleware?

otherwise is there a designed way of handle this situation?

ssr is disabled, and everything runs client side.
GitHub
The Intuitive Vue Framework. Contribute to nuxt/nuxt development by creating an account on GitHub.
nuxt/packages/nuxt/src/app/composables/router.ts at 9b689ea8261bc65...
Was this page helpful?