Surreal
Surreal
NNuxt
Created by Surreal on 11/12/2024 in #❓・help
i18n and route rules
I'm using the latest version of Nuxt + @nuxtjs/i18n configured with strategy: 'prefix_except_default' and recently noticed something odd - my route rules aren't being applied to prefixed paths. For example, routeRules: { '/foobar': { ssr: false } } only applies to /foobar, not the prefixed /fr/foobar path. It's relatively easy to work around by adding unique route rules for every language, for every path, but it does quickly multiply the number of route rules which is annoying. I was just wondering - does anyone happen to know if this has always worked this way, or if it may be a newish bug? I've been running Nuxt + i18n in production with a half dozen languages for at least a year, but this is the first time I noticed the route rules only applying to the default language's (non-prefixed) path.
5 replies
NNuxt
Created by Surreal on 7/24/2024 in #❓・help
How to access buildId/build hash at runtime?
I've been trying to figure out how to access the build id/hash on the server side at runtime, so that I can build something from the client side to detect when a new version of my code has been released (e.g., expose the build hash via server API, periodically query it or build a websocket to monitor for change, etc.). Anyone know how to do this? The only things I've been able to find in this vein require either (1) hardcoding the buildId via config, or (2) intercepting, overriding, and storing the default hash generation in the "build:before" lifecycle hook. I'm hoping there's just a simpler, out-of-the-box way to access the existing generated ID. Thanks in advance!
3 replies
NNuxt
Created by Surreal on 5/22/2024 in #❓・help
How to get cookie value in SSR page?
I'm probably missing something, but I'm not understanding why I can't access a cookie value from a server-side rendered page. In a most basic sense, why doesn't {{ useCookie('foobar') }} show the value of that cookie in the server-side rendered HTML? It works correctly when the page is rendered client-side, and I can get the cookie value using getCookie() in a /server/api/ endpoint -- but I was under the assumption that useCookie is "SSR-friendly" and should be able to retrieve the cookie value for the server-rendered page?
6 replies