When I read the country code from cookies and make defaultLocale based on it, NEXT_LOCALE is not in cookies and a 404 page is displayed! #1494
Unanswered
kliatskiidenis
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi friends, help me figure it out because I'm already confused, please!
I have a project on Nextjs 14 with app routing using next-intl with app router
When accessing the site, I receive, through a third-party API, the country code from which the user enters and write it to cookies so as not to constantly request the country code.
then I read this cookie with the country code and make a defaultLocale that I pass to handleI18nRouting
there is also an additional check that the user did not come from google.com because if the referrer is google.com, then you need to use the language that was in the link from google and not change it.
So, when I check the functionality, clear the cookies in the browser, go to the site, the cookie with the country code is recorded all right, and the NEXT_LOCALE cookie is missing and the browser shows a 404 error
if you just reload the browser again, the NEXT_LOCALE cookie appears and the site is displayed
by the way, if you just constantly make a request and use the received code directly without writing it to cookies, then this 404 page is not there, everything seems to be fine
I'm attaching the full code of my middleware.ts file, please tell me what I'm doing wrong, why the 404 page at first
Beta Was this translation helpful? Give feedback.
All reactions