next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

version 5.11.3 doesn't seem to pass the correct locale anymore from middleware.

Open BArtistically opened this issue 5 months ago • 1 comments

in version 5.11.3 when using middleware, the locale is not passed anymore. It is still present in the middleware but in the getStaticProps it defaults to the default. Even when only returning NextResponse.next(); in version 5.11.2 everything was still ok. Can someone check what made it break. Currently reverting to 5.11.2 until it is fixed.

BArtistically avatar Jun 23 '25 07:06 BArtistically

Hi @BArtistically I did reproduce problems with NextResponse.rewrite() resulting in always having default locale in getServerSideProps or getStaticProps. But I did not manage to reproduce the problems with NextResponse.next()

For now I don't yet have a fix but at least added more assertions around locale in https://github.com/opennextjs/opennextjs-netlify/pull/2984 with those failing for rewrite case.

Even when only returning NextResponse.next();

As mentioned, I have trouble with reproducing this part, so I would appreciate if you could double check if that part is actually correct and if it is, it would be really helpful if you could share some kind of reproduction

pieh avatar Jun 27 '25 14:06 pieh

Digging a bit more, I did realize that rewrite failures I mentioned above was result of doing locale-aware rewrite wrong in our test fixture and after addressing that - now NextResponse.rewrite() cases also work fine (see https://github.com/opennextjs/opennextjs-netlify/pull/2984#discussion_r2174655698 for change I did to fix the middleware rewrite in the fixture).

So at this point I'm just unable to reproduce reported problems and I'm blocked on this issue unless you could produce reproduction

pieh avatar Jun 30 '25 10:06 pieh

Hi, sorry for the late response. When I start the project locally using the netlify cli, it works but when I deploy on netlify all the ..json files give a 404 caused by the locale in the getStaticProps being the default 'en' instead of the correct locale. When I check the locale in the middleware, it's still correct.

BArtistically avatar Jul 08 '25 06:07 BArtistically

Is your Next.js version older than 14.2.7? I finally was able to reproduce problems, but only when Next.js is older than 14.2.7 and the target page is part of dynamic route

pieh avatar Jul 10 '25 18:07 pieh