So I am getting this warning in nuxt3:
Calling useRoute within middleware may lead to misleading results. Instead, use the (to, from) arguments passed to the middleware to access the new and old routes.
发生这种情况是因为我在中间件中调用<code>useLocalePath()</code>。
这是发生这种情况的中间件之一:
export default defineNuxtRouteMiddleware(async(to, from) => {
const localPath = useLocalePath()
const isUserAuthenticated = await isAuthenticated()
if (isUserAuthenticated) {
if (to.fullPath === localPath( login ) || to.fullPath === localPath( register )) {
return navigateTo(localPath( / ))
}
} else {
if (to.fullPath !== localPath( login ) && to.fullPath !== localPath( register )) {
return navigateTo(localPath( login ))
}
}
})
我的nuxt.config.ts中有这个:
i18n: {
lazy: true,
langDir: "locales",
strategy: "prefix_and_default",
locales: [
{
code: nl-Nl ,
iso: nl-Nl ,
name: Dutch ,
file: nl-NL.json
},
{
code: en ,
iso: en ,
name: English ,
file: en.json
},
],
detectBrowserLanguage: {
useCookie: true,
cookieCrossOrigin: true,
alwaysRedirect: true,
cookieKey: i18n_redirected ,
redirectOn: root
},
defaultLocale: "nl-Nl",
customRoutes: config ,
pages: {
pricing: {
en: /pricing ,
nl-Nl : /prijzen ,
}
}
}
This is the version of i18n that i m using:
"@nuxtjs/i18n": "^8.0.0-beta.12",
问题是,代码运行得很好,但我不知道它为什么会给我这个警告。
忽视这个警告安全吗?