Next middleware not executed on navigation causing locale errors #829
Unanswered
bkrajewski94
asked this question in
Q&A
Replies: 1 comment
-
The solution that can be considered as working is to combine hard reload (so that state / client cache is lost) with "history replace". I did it like this:
Using the Link component will cause a "soft" reload (state and cache won't be lost) that's why I had to call window.location.replace manually (and the a tag is there for semantics / seo). Any idea of a better solution? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I've encountered a tricky problem related to Next 14 middleware and browser navigation.
When you move back and forth between pages the browser has already loaded using the browser nav, there seems to be no network request to the server (see here), thus middleware is not executed. Now imagine the following scenario:
/job/driver
for English and/de/arbeit/fahrer
for German (so/de/job/driver
or(en)/arbeit/fahrer
won't work)/job
path and click a link that navigates you to/job/driver
/de/arbeit/fahrer
/job/driver
and everything is in english, but the locale cookie is still 'de'/job/waitress
but because it's a new page (new server request) middleware kicks in, and adds the locale to the url/de/job/waitress
that causes 404Has anyone had to deal with this problem? Any solutions?
Beta Was this translation helpful? Give feedback.
All reactions