如何从 Nuxt 3 服务器获取 localePath() ?
// server/api/[...].ts
export default NuxtAuthHandler({
// The secret is used to encrypt the JWT token
secret: useRuntimeConfig().auth.secret,
// Redirects to this page if the user is not authenticated
pages: {
// * How to get the locales Path and return?
signIn: '/zh-TW/auth/', // '/en-US/auth/'
},
....
i18n 只能在 Nuxt3 中使用,而不能在 Nitro 中使用。我可以做什么来将具有区域设置路径的路径从服务器重定向到前端?
这不是最好的方法,但您可以使用 cookie 来了解区域设置。为此,您可以使用
parseCookies()
,如文档中所示。
export default defineEventHandler((event) => {
...
const cookies = parseCookies(event)
...
})
如果我找到更好的方法,我会更新此回复。