Using next-international makes the app forget the language.

I have my app built and deployed to cloudflare. I have added internationalization using next-international. When I change the language in local, it is kept, and the text is changed accordingly, but when I push the code and it is deployed in Cloudflare, it does not happen anymore. I could post a video if required. Or access to the deployed environment deployed in CF Pages.
13 Replies
Eusebio Trigo
Eusebio TrigoOP8mo ago
GitHub
GitHub - Eusebiotrigo/next-international-cloudflare: Check what's g...
Check what's going on with next international and Cloudflare - Eusebiotrigo/next-international-cloudflare
Eusebio Trigo
Eusebio TrigoOP8mo ago
One issue opened to the library makers in https://github.com/QuiiBz/next-international/issues/397
GitHub
Using Cloudflare Pages forgets the selected language · Issue #397 ·...
Describe the bug I have a language switcher like: const changeLocale = useChangeLocale(); const currentLocale = useCurrentLocale(); const handleLocaleChange = (event: ChangeEvent<HTMLSelectEleme...
Eusebio Trigo
Eusebio TrigoOP8mo ago
I would just like to understand if this is due to the library or how @cloudflare/next-on-pages builds it or if it is the edge-runtime... etc.
osa
osa8mo ago
Not sure what causes this exactly, but what's happening is when you click EN or FR in SSR mode, it does not actually return any cookie to the client from RSC. I don't know if this is a bug in the way next-on-pages handles RSC or is it something related to the library.
osa
osa8mo ago
No description
No description
Eusebio Trigo
Eusebio TrigoOP8mo ago
Thanks for checking it! At least a cookie should be sent so the middleware can do wonders... but I don't know where to look at... The cookie seems like a good starting point anyway. I've been digging more on this.... and I am console logging the value of the cookie and it never changes. This is from my real app in local Cookie "Next-Locale": { name: 'Next-Locale', value: 'de' } ✓ Compiled /api/connect/systems/[system_id] in 272ms (2898 modules) GET /api/connect/systems/rec_cl572ai0kf4emdrkk35g 200 in 345ms Cookie "Next-Locale": { name: 'Next-Locale', value: 'de' } PathName: /en/comply/ledger Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } But in CF Deployed app: GET https://79cccbf6.control-center.pages.dev/en/comply/ledger - Ok @ 5/9/2024, 12:08:51 PM (log) Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } (log) PathName: /en/comply/ledger GET https://79cccbf6.control-center.pages.dev/comply/ledger/sellers?_rsc=z4fzl - Ok @ 5/9/2024, 12:08:52 PM (log) Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } (log) PathName: /comply/ledger/sellers GET https://79cccbf6.control-center.pages.dev/en/comply/ledger/sellers - Ok @ 5/9/2024, 12:08:52 PM (log) Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } (log) PathName: /en/comply/ledger/sellers GET https://79cccbf6.control-center.pages.dev/comply/e-invoicing?_rsc=z4fzl - Ok @ 5/9/2024, 12:08:57 PM (log) Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } (log) PathName: /comply/e-invoicing GET https://79cccbf6.control-center.pages.dev/en/comply/e-invoicing - Ok @ 5/9/2024, 12:08:57 PM (log) Cookie "Next-Locale": { name: 'Next-Locale', value: 'en' } And I've checked that the application deployed in Cloudflare does not change the cookie, whereas it changes the cookie in local environment. Running it in dev mode and running it from the built dir in local, it works. Running it in the Cloudflare doesn´t.
osa
osa8mo ago
Have you tried it on a custom host? Maybe pages.dev is stripping the cookies or something.
Eusebio Trigo
Eusebio TrigoOP8mo ago
I just tried in local. Good one. I will set it up on Vercel. https://next-international-cloudflare.vercel.app/fr This is on Vercel. It works there.
Eusebio Trigo
Eusebio TrigoOP8mo ago
I have this issue opened in the repo https://github.com/cloudflare/next-on-pages/issues/785
GitHub
[🐛 Bug]: Next-International does not work deployed in Cloudflare · ...
next-on-pages environment related information System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 CPU...
Nob
Nob8mo ago
@Eusebio Trigo RSC can't edit cookies you need a middleware for that
Eusebio Trigo
Eusebio TrigoOP8mo ago
Yeah. It is in the middleware where this library changes the cookie. In the deployed version in Cloudflare Pages it seems that it does not go through the middleware (I put an old console.log there). So on every request and URL change the mw should hit. And the cookie should change.
Nob
Nob8mo ago
weird because for supabase auth the middleware can edit cookie
Eusebio Trigo
Eusebio TrigoOP8mo ago
In vercel it works. In local as well. And I lack knowledge on what happens when it is deployed on CF 😦
Want results from more Discord servers?
Add your server