Closed darthf1 closed 8 months ago
Would you be able to provide a reproduction? π
Closing this due to inactivity and lack of reproduction, if you're still experiencing this issue please open a new issue with a (minimal) reproduction.
Hi @BobbieGoede, apologies for not providing one sooner:
https://stackblitz.com/edit/bobbiegoede-nuxt-i18n-starter-gzk2eb?file=middleware%2Ftest.ts
From the index, if you follow the URL to the test page you will see an error with the to
object. You can see theres a difference between 8.0.0
and 8.0.1
.
If the navigation does nothing, remove the throw new Error
from the middleware, and add it back after you navigated.
@darthf1 Thanks for the reproduction!
It's interesting that this worked in 8.0.0
, is there a specific reason why you're using test.vue
as opposed to test/[id].vue
? I have made some changes to your reproduction to make things work (I assume) as expected here.
The things I changed:
name
in localePath
to matchpaths
syntax in defineI18nRoute
If you have any questions let me know!
@darthf1 Thanks for the reproduction!
It's interesting that this worked in
8.0.0
, is there a specific reason why you're usingtest.vue
as opposed totest/[id].vue
? I have made some changes to your reproduction to make things work (I assume) as expected here.The things I changed:
* pages structure * `name` in `localePath` to match * `paths` syntax in `defineI18nRoute`
If you have any questions let me know!
Ah, thanks for looking into it!
No there's no specific reason, other than this is a big app which originated in Vue 2/Nuxt 2, so it was a quite a painful migration to Vue 3/Nuxt 3. And since this worked I never looked any further/ deeper.
Thank you for providing a fixed reproduction. Reading the docs I guess this is the more Vue/Nuxt preferred way of dealing with these kind of routes?
Is it possible to "restore" the behavior as it was in 8.0.0
? Making the changes you have but in my app is going to take significant effort, so just looking for options :)
Actually after looking into it some more, it seems like just changing the paths
syntax in defineI18nRoute
is sufficient see this reproduction.
This was probably caused by #2711, which actually fixes the route segment parsing to be the same as that of Nuxt. I don't think providing parameters only in defineI18nRoute
is documented behaviour, and this may cause unexpected behaviour down the road with other Nuxt functionalities, or break in future releases.
Hope this helps!
Environment
Build Modules: -
Reproduction
-
Describe the bug
When I upgrade from
8.0.0
to8.0.1
, the parameter values in theto
parameter in thedefineNuxtRouteMiddleware
are not resolved.When I put a
console.error(to)
in an (async) middleware, I get:8.0.1
:8.0.0
:Additional context
No response
Logs
No response