Skip to content

Commit

Permalink
fix: cookie being reset on reload in ssg build
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Sep 4, 2024
1 parent ebbc7f4 commit e1afaa2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runtime/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default defineNuxtPlugin({
* avoid hydration mismatch for SSG mode
*/
if (isSSGModeInitialSetup() && runtimeI18n.strategy === 'no_prefix' && import.meta.client) {
const initialLocaleCookie = localeCookie.value
nuxt.hook('app:mounted', async () => {
__DEBUG__ && logger.log('hook app:mounted')
const detected = detectBrowserLanguage(
Expand All @@ -160,7 +161,7 @@ export default defineNuxtPlugin({
ssg: 'ssg_setup',
callType: 'setup',
firstAccess: true,
localeCookie: getLocaleCookie(localeCookie, _detectBrowserLanguage, runtimeI18n.defaultLocale)
localeCookie: initialLocaleCookie
},
initialLocale
)
Expand Down

0 comments on commit e1afaa2

Please sign in to comment.