-
-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: failure to change locale on initial try with nuxt generate
When generating static files with `nuxt generate` (with default `universal` mode), initial load of the URL doesn't trigger middleware. Nuxt triggers middleware in those cases for initial load: - universal (server: yes, client: no) - spa (server: --, client: yes) - universal+generate (server: --, client: no) - spa+generate (server: --, client: yes) Due to middleware not triggering on initial load, browser language wasn't detected and cookie was not set, which later caused failure to update locale on navigating to route from other locale. That's because detection happened on second navigation and overridden target route's locale. To fix, trigger language detection from the plugin first. For some cases that means that middleware will attempt to trigger detection again but it will be short-cut early as cookie will already be there or target locale will already be set. Also cleaned up some imports and unused variables in middleware and plugin (more cleanup is possible). Resolves #378
- Loading branch information
Showing
4 changed files
with
125 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ node_modules | |
.idea | ||
*.log* | ||
.nuxt | ||
.nuxt-generate | ||
.vscode | ||
.DS_STORE | ||
coverage | ||
dist | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters